Implicit Intent

First, when you create Intent instance, does not directly pass in the name of the Activity needs to be called. And their passing in a action

Intent intent = new Intent("com.example.helloworld.THIRD_START");

Second, we need to add is called activity corresponding action during registration. Note that there is also need to add at least one category.

            <intent-filter>
                <action android:name="com.example.helloworld.THIRD_START"/>
                <category android:name="android.intent.category.DEFAULT"/>

            </intent-filter>

Third, so that you can start the Intent. It should be noted here does not add category in the Intent. This is because android.intent.category.DEFAULT is the default category is added.

startActivity(intent);

Four, category and registration category If you add in the intent does not match. An exception will occur.

Intent intent = new Intent("com.example.helloworld.THIRD_START");
intent.addCategory("com.example.helloworld.OTHER");
startActivity(intent);

 

Guess you like

Origin www.cnblogs.com/xxie12/p/11469789.html