android - How to resume an application from another application? -


actually, know how launch application application.

the problem application restarts instead of resuming when launch application after launching home screen. (i mean application running first pressing shortcut home screen)

for example, there 2 applications : a, b

  1. launch 2 applications home screen first.
  2. launch application again b application.
  3. a application restarts instead of resuming.

how resume it? doing below.

intent intent = getpackagemanager().getlaunchintentforpackage(package); intent.setaction(action); intent.setflags(intent.flag_activity_new_task|intent.flag_activity_single_top); startactivity(intent); 

action custom action. please help.

you can check intent.category_launcher category , intent.action_main action in intent starts initial activity. if 2 flags present , activity not @ root of task (ie.. app running), call finish() on initial activity. exact solution may not work you, similar should.

here in oncreate() of initial/launch activity:

if (!istaskroot()         && getintent().hascategory(intent.category_launcher)         && getintent().getaction() != null         && getintent().getaction().equals(intent.action_main)) {      finish();     return; } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -