Sandeep
Sandeep

Reputation: 41

Launch apps using its package name and bring it to front if it is already running

How to launch any app like messenger,chrome,etc by using its package name but if the launched is already running on the background I want it to just bring to front.I don't want to create new instance of it Is there any solution.I am testing my app on api 23 (lollipop).

Upvotes: 0

Views: 489

Answers (1)

Andrey Danilov
Andrey Danilov

Reputation: 6612

Checked, this code works like charm.

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.abc");
LaunchIntent .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity( LaunchIntent );

Upvotes: 3

Related Questions