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
- launch 2 applications home screen first.
- launch application again b application.
- 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
Post a Comment