android - How to close my application when clicking on a notification? -
i created notifications , when click on notification startactivity. works perfectly, when application has not been started.
the problem have when open notification since previous activity remains open.
my intention when click on notification close current application , contain new call notification.
i've tried showing in "androidmanifest" "android:launch=" , flags on pendingintents haven't run it.
any help? thanks
edit: application starts follows:
splashscreen.class -> main.class (is tabactivity)
when click on notification following: splashscreen.class -> main.class (is tabactivity)
but if application started , pulse on notification, have:
new - splashscreen.class -> main.class (is tabactivity) (current) older. , below still open above main.class
if need open splashscreen.class when click notification try create intent this:
intent intent = new intent(mycontext, splashscreen.class); intent.setflags(intent.flag_activity_clear_top);
as documentation says intent.flag_activity_clear_top
if set, , activity being launched running in current task, instead of launching new instance of activity, of other activities on top of closed , intent delivered (now on top) old activity new intent.
for example, consider task consisting of activities: a, b, c, d. if d calls startactivity() intent resolves component of activity b, c , d finished , b receive given intent, resulting in stack being: a, b.
the running instance of activity b in above example either receive new intent starting here in onnewintent() method, or finished , restarted new intent. if has declared launch mode "multiple" (the default) , have not set flag_activity_single_top in same intent, finished , re-created; other launch modes or if flag_activity_single_top set intent delivered current instance's onnewintent().
so when launch splashscreen activity flag, if on stack brought top , other activities above on stack cleared
Comments
Post a Comment