Implicitly intent, the target component name is not explicitly indicated, as opposed to an explicit intent ( intent that explicitly indicates the target component name) . Explicit intent defines the target component directly with the name of the component, which is straightforward. But because developers often don't know the component names of other applications, explicit intent is more used to deliver messages inside the application. For example, within an application, an activity initiates a service. Implicit intent, on the contrary, does not define the target component that needs to be activated with the component name, which is more widely used to pass messages between different applications. In an explicit intent message, the only element that determines the target component is the component name, so if the name of the target component has been explicitly defined in intent, then no additional intent content is defined at all. For implicit intent, however, because there is no explicit target component name, the Android system must help the application find the component that best matches the intent of the intent request.
Implicit Intent specifies a series of more abstract actions and category information, which are then referred to the system for analysis. By configuring <intent-filter> on the <activity> tab, you can define the action and category for the current activity. Add an article to the Androidmanifest.xml:
<activity android:name=". Secondactivity"> <intent-filter> < Action android:name="com.example.myintent.ACTION_START"/> <category android : Name="android.intent.category.MY_CATEGORY"/> </intent-filter> </activity>
Activity
Also modify the code in the mainactivity:
1 Public classMainactivity extends Activity {2 3 PrivateButton btn1;4 5 @Override6 protected voidonCreate (Bundle savedinstancestate) {7 super.oncreate (savedinstancestate);8 Setcontentview (r.layout.activity_main);9 Tenbtn1=(Button) Findviewbyid (r.id.button1); OneBtn1.setonclicklistener (NewOnclicklistener () { A - @Override - Public voidOnClick (View arg0) { the //TODO auto-generated Method Stub - //an explicit - //Intent intent=new Intent (mainactivity.this,secondactivity.class); - //startactivity (intent); + - //Implicit +Intent intent=NewIntent ("Com.example.myintent.ACTION_START"); AIntent.addcategory ("Android.intent.category.MY_CATEGORY"); at startactivity (intent); - } - }); - } - - in}OnClick
Only the action and category match at the same time, a intent can have only one action, but it may have multiple category. When the category is not added in <intet-filter>, the system will not error and will use the default category.
Android Intent (implicit)