One of the keys to understanding intent is to understand the two basic usages of intent: an explicit intent that designates the receiver when constructing the intent object, similar to a normal function call, and an implicit intent, That is, when the sender of the intent constructs the intent object, it does not know or care who the receiver is, which is quite different from the function call, which helps to reduce the coupling between sender and receiver. In addition, intent can also be used for broadcasting in addition to sending.
Display call 1.Intent Intent = new Intent (); Intent.setclass (A.this,b.class); Intent.setclassname ("Com.view", "com.view.b"); The former is the package name of a, the latter is the class name of the B
StartActivity (Intent);
Implicit invocation: private static String my_action = "Com.view.my_action";
Intent Intent = new Intent (); Intent.setaction (my_action);
or//Intent Intent = new Intent (my_action);
StartActivity (Intent);
Implicit invocation is not only declared in the Androidmanifest.xml file, but also added Intent-filter
In the activity of Class B, add:
<intent-filter>
<action android:name= "Com.view.my_action"/> <!--customization
</intent-filter>
With this sentence, you can jump to class B.
If you want to start another application, such as Class B is at the entrance of another application, add another intent-filter to its activity
<activity android:name= ". B "android:label=" @string/app_name ">
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name= "Com.view.my_action"/>
<action android:name= "Android.intent.action.DEFAULT"/>
<category android:name= "Android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Android intent implicitly invokes one application to launch another application (reprinted)