I use the following code to launch other apps:
Intent intent = new Intent();
intent.addCategory(CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(packageName, activity));
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
This works however it makes the launched app start from the beginning, not from the last opened activity (resuming it). Is there something wrong with my code?
Use a "launch Intent
", like this:
Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
startActivity(intent);
This Intent
has all the necessary flags and settings to bring an existig task to the foreground or to start a new one (if the app is not running).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.