android - Bring the app to front if it is already running rather than creating new instance of it -
i launching system apps app , can launch using code
intent i=getpackagemanager.getlaunchintentforpackage("your package name"); i.setflags(intent.flags_reorder_to_front); i.setflags(intent.flags_single_top); startactivity(i);
but restarted or created new instance of app.if particular app running want bring front rather creating new instance of it.. have tried many methods didn't worked created new instance on top of running app. please solve problem
it depends on launch mode of activity want start.
if launch mode "standard" not possible bring front:
a new instance always created new intent when launch mode "standard" (source)
for other launch modes, try using following 2 flags:
i.setflags(intent.flag_activity_new_task); i.setflags(intent.flag_activity_clear_top);
as described in documentation should have following effect (which should match desired behavior):
flag_activity_clear_top
used in conjunctionflag_activity_new_task
. when used together, these flags way of locating existing activity in task , putting in position can respond intent.
Comments
Post a Comment