Alex Kay
Alex Kay

Reputation: 289

Programmatically open an external app as popup in Android

One can open an external app like this:

myIntent = Intent(Intent.ACTION_VIEW)
startActivity(myIntent)

which opens the external app in full screen without an obvious way for the user to return to the original app.

In iOS when you open the SMS app using MFMessageComposeViewController it comes up as a popup. Once the user dismisses the SMS app they are automatically back in the original app.

Is there a way to do this in Android?

Upvotes: 0

Views: 900

Answers (1)

Top4o
Top4o

Reputation: 674

SDK > 30 (Android 11) add this to your manifest:

<queries>
    <package android:name="com.package.name" />
</queries>

After that you can simply do:

Intent intent = getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.package.name");
startActivity(intent);

EDIT:

If the user has put the device into a multi-window mode, you can use FLAG_ACTIVITY_LAUNCH_ADJACENT to try to launch the other activity into a separate window.

Upvotes: 2

Related Questions