简体   繁体   中英

Activity with Intent.FLAG_ACTIVITY_NEW_TASK has been destroyed

I'm using this way to start activity from Service, if my app is background:

        Intent intent = new Intent(this, FromBackgroundActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

it works perfect, but if FromBackgroundActivity is active and I press Home key it puts all to background. And if I click on my app in taskbar it restores my app to foreground but without FromBackgroundActivity , it is destroyed. ( how can i restore my app from background with FromBackgroundActivity ?

Try intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));

It'll clear all the task and go to the FromBackgroundActivity.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM