Define external application action in AndroidManifest.xml, Master & Child Activity

I have quite a few actions expanding the parent activity called MasterActivity, which centralizes all the common functions used in child actions, including the side menu. I would like to run an application that has a custom action:

com.example.otherapp.action.CUSTOMACTION

Here AndroidManifest.xml:

<activity android:name=".MasterActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="com.example.otherapp.action.CUSTOMACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

In MasterActivity.java:

Intent intent = new Intent();
intent.setAction("com.example.otherapp.action.CUSTOMACTION");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

When I go to one of my child operations in the application, it shows an Exception:

No actions found to control Intent

and crashed. However, when I added the following entry to AndroidManifest.xml, it will start the action selector:

<activity android:name=".ChildActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="com.example.otherapp.action.CUSTOMACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

, intent-filter. ?


, , ? :

Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

.

+4

All Articles