launch activities from different package

I am assuming that by “packages” you mean applications.

We have:
– ApplicationA with FirstActivity
– ApplicationB with SecondActivity

If, in the ApplicationB’s AndroidManifest.xml file, in the declaration of SecondActivity you add an intent filter such as:

<activity android:name=".SecondActivity">
  <intent-filter>
    <action android:name="applicationB.intent.action.Launch" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>

You can create an Intent to launch this SecondActivity from the FirstActivity with:

Intent intent = new Intent("applicationB.intent.action.Launch");
startActivity(intent);

What this all means is:

  • The SecondActivity has a filter for the intent action of “applicationB.intent.action.Launch”
  • When you create an intent with that action and call ‘startActivity’ the system will find the activity (if any) that responds to it

The documentation for this is at: https://developer.android.com/reference/android/content/Intent.html

Leave a Comment