first, the explicit type intent:startactivity (New Intent (Mainactivity.this, class name));
Second, implicit intent:
1. Register <activity> tags in the <application> tab of the Androidmanifest.xml file, like the. Class name: <activity android:name =". Another " android:exported=" false " > <intent-filter > <action android:name= "Com.example.jikexueyuan_ Learnintent.intent.action.another "/> <category android:name= "Android.intent.category.DEFAULT"/> </intent-filter> </ activity> NOTE: The exported property is the ability to reference or open this activity in other apps, that is, whether it can be exported & nbsp Intet-filter in the,<action> tag, give the activity a name, any (generally: package name. intent.action. Class name) <category> tags, is generally android.intent.category.DEFAULT. 2. In the called Class, StartActivity (New Intent (",<action> tag in Intet-filter, name of the activity"); Findviewbyid (R.id.btn_startanotheraty). Setonclicklistener (New Onclicklistener () {@Override Publ IC void OnClick (View v) {//TODO auto-generated method stub try {startactivity (New Intent ("Com.example.jikexueyuan_learnintent.intent.action.another"));} catch (Exception e) {//Todo:handle Exception Toast.maketext (mainactivity.this, "Unable to start", Toast.length_short). Show (); //Use of toast}}); 3. You can also directly define a class B that you want to open with another public static constant string Public static final String Action = "Com.example.jikexueyuan_learnintent.intent.action.another";It is then easier to understand that when called, the activity name is changed to the class name b.action. namely:startactivity (New Intent (another.action)); Three,Intent filter related options: Create two new apps (APP1 and APP2) in one app and register <activity> tags in the <application> tab of the Androidmanifest.xml file, like the. class name; Intet-filter,<action> tag, give this; two activity takes the same name. The APP3 invokes the program startactivity (New Intent ("name")), and the result is as follows : You will be prompted to select the app to run (1 run once only 2 is set as default), if you set APP1 todefaultToCancel, just inSettings-"Application-" app1-"(default startup in application information) clear default settingsIn one of the apps (like APP1), add the data tag to the <application> <intent-filter > in the Androidmanifest.xml file. and define a protocol for the app: <data android:scheme= "app"/> (to see what other tags mean) go back to APP3 's calling program startactivity (New Intent ("name")); Add, uri.parse ("app://") field. That startactivity (New Intent ("name", Uri.parse ("app://" )); (app://can be added to any field lake or not added later)
The concept and application of Intent in Android