Nguyen Ba Thanh
- Forum posts: 14
Apr 8, 2013, 8:06:40 AM via Website
Apr 8, 2013 8:06:40 AM via Website
9android developer has release new tutorial for new beginer about Intent android.
today, i introduce you how to use android intent in this article in summary.
View full tutorial and download sample source at http://www.9android.net/intent-basic/
Using Intent
1. Launching to Activities
To start Activities, we must make two steps as follow:
Step 1: Declare Activity in Manifest.
Step 2: Create Intent to call the Activity.
2.2. Start Service
To start Services, we must make two steps as follow:
Step 1: Declare Service in Manifest.
Step 2: Create Intent to call the Service.
2.3. Send BroadcastReceiver
To start BroadcastReceiver, we must make two steps as follow:
Step 1: Declare BroadcastReceiver in Manifest.
today, i introduce you how to use android intent in this article in summary.
View full tutorial and download sample source at http://www.9android.net/intent-basic/
Using Intent
1. Launching to Activities
To start Activities, we must make two steps as follow:
Step 1: Declare Activity in Manifest.
1<activity
2 android:name=".SecondActivity"
3 android:label="@string/title_activity_second" >
4 <intent-filter>
5 <action android:name="android.intent.action.MAIN" />
6
7 <category android:name="android.intent.category.LAUNCHER" />
8 </intent-filter>
9 </activity>
2 android:name=".SecondActivity"
3 android:label="@string/title_activity_second" >
4 <intent-filter>
5 <action android:name="android.intent.action.MAIN" />
6
7 <category android:name="android.intent.category.LAUNCHER" />
8 </intent-filter>
9 </activity>
Step 2: Create Intent to call the Activity.
1Intent secondActivity = new Intent(this, SecondActivity.class);
2 startActivity(secondActivity)
;2 startActivity(secondActivity)
2.2. Start Service
To start Services, we must make two steps as follow:
Step 1: Declare Service in Manifest.
1<service android:name="MyService" >
2 </service>
2 </service>
Step 2: Create Intent to call the Service.
1Intent myServiceIntent = new Intent(this, MyService.class);
2 startService(myServiceIntent);
2 startService(myServiceIntent);
2.3. Send BroadcastReceiver
To start BroadcastReceiver, we must make two steps as follow:
Step 1: Declare BroadcastReceiver in Manifest.
1<receiver android:name="MyBroadcastReceiver" >
2 <intent-filter>
3 <action android:name="com.example.intenttutorial.myrecevier" />
4 </intent-filter>
5 </receiver>
Step 2: Create Intent to send the BroadcastReceiver.2 <intent-filter>
3 <action android:name="com.example.intenttutorial.myrecevier" />
4 </intent-filter>
5 </receiver>
1Intent broadcastIntent = new Intent(broadcastFilter);
2 broadcastIntent.putExtra("9Android.net","MyBroadcastReciver is called!");
3 sendBroadcast(broadcastIntent);
2 broadcastIntent.putExtra("9Android.net","MyBroadcastReciver is called!");
3 sendBroadcast(broadcastIntent);
— modified on Apr 15, 2013, 7:03:29 AM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.