Reputation: 41
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
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