The use of intent is divided into two categories:
I. Using an explicit intent
The explicit intent is to explicitly provide the current context and the context in which to jump the activity when instantiating intent, as shown in the following code:
New Intent (mainactivity. this, otheractivity. class ); startactivity (intent);
Second, the use of implicit intent
Implicit intent does not explicitly specify which activity to start, but rather by specifying the action and category, which activity is initiated by system analysis, in the following steps:
1, registered in the Androidmanifest.xml is initiated activities
<ActivityAndroid:name=". Otheractivity "> <Intent-filter> <ActionAndroid:name= "Com.xxx.yyy.ACTION_START" /> <categoryAndroid:name= "Android.intent.category.DEFAULT" /> <categoryAndroid:name= "Com.xxx.yyy.zzz" /> </Intent-filter></Activity>
2. Instantiate intent in the keynote activity and add category to intent
New Intent ("Com.xxx.yyy.ACTION_START"); Intent.addcategory ("com.xxx.yyy.zzz"); StartActivity (Intent) ;
More usages of implicit intent
By implicit intent, it makes it possible to start the activities of other applications, such as
1. Start the browser to open the Web page:
New Intent (Intent.action_view); Intent.setdata (Uri.parse ("http://www.baidu.com/")); StartActivity ( Intent);
2. Start dialing:
New Intent (intent.action_dial); Intent.setdata (Uri.parse ("tel:10086")); StartActivity (Intent) ;
"Android first line code" learning record 03-switching activities using intent