Thursday, 15 March 2012

Android deep-linking. Intent doesn't reset when app is opened from history -



Android deep-linking. Intent doesn't reset when app is opened from history -

i have problem regarding android task , intent management.

scenario

user gets force deep-link app. we show notification putting uri intent data. user clicks notification , taken app , redirected feature1activity described deep-link. user looks around, , backs out of app. later, user opens app history (long-press home or multitasking button). now same intent used notification (with deep-link in intent data) used start app. hence, user taken feature1activity again.

problem:

starting app history (long-press home or multitasking button) not reset task (which when launching app icon).

i understand starting app history not supposed reset task since intended used "get-right-back-where-you-were". however, in case issue since launch of app notification 1 time thing.

anyone else encountered problem? know solution?

more in-depth

the intent within pendingintent built this:

intent intent = new intent (intent.actionview); intent.addflags (intent.flag_activity_new_task); intent.addflags (intent.flag_activity_clear_top); intent.addflags (intent.flag_activity_clear_when_task_reset); intent.setdata (uri.parse (deep_link_url));

i found out flag_activity_clear_when_task_reset day , thought git rid of problem made no difference.

there 3 activities of interest:

splashactivity (main launcher & listener of deep-linking schema -- activity redirects either login or overviewactivity) overviewactivity (authorized user's main activity) feature1activity (any feature deep-link pointing to)

what happens when user clicks notification splashactivity acts listener schema , converts deep-link url 2 intents start overviewactivity , feature1activity using activity.startactivities (intent[]).

when @ intent notification within splashactivity contain deep-link in data.

one work around

there work around, setting booleanextra field notification intent (for instance "ignorewhenlaunchedfromhistory" = true) , check in splashactivity before redirecting

boolean fromhistory = (getintent().getflags() & flag_activity_launched_from_history) == flag_activity_launched_from_history; if (fromhistory && getintent().getbooleanextra ("ignorewhenlaunchedfromhistory", false)) // don't follow deep-link if exists else // follow deep-link

except hackish , ugly, can see problems work around?

edit: work around works when responsible sending intent deep-link. since no external source can know "ignorewhenlaunchedfromhistory" extra.

from get, maybe using android:excludefromrecents="true"on manifest (as property activity declaration) might ameliorate issue?

android android-intent

No comments:

Post a Comment