Starting app only if its not currently running

Use a “launch Intent” for your app, like this:

PackageManager pm = getPackageManager();
Intent launchIntent = pm.getLaunchIntentForPackage("your.package.name");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, launchIntent, 0);

Replace “your.package.name” with the name of your package from the Android manifest.

Also, you should remove the special launchMode="singleTask" from your manifest. Standard Android behaviour will do what you want.

Leave a Comment