android - Activity sopped when should be started -


i create notification service. notification contains intent create activity a :

... intent intent = new intent(this, a.class); intent.addflags(intent.flag_activity_clear_top); ... 

and activity a, when receives intent, create activity b using same flag.

problem is: when show nothing (app closed or in background), works. when click on notification , activity a shown, works , have trace:

onactivitypaused(com.*****.a) onactivitycreated(com..*****.a) onactivitystarted(com..*****.a) onactivityresumed(com..*****.a) onactivitypaused(com..*****.a) onactivitycreated(com..*****.b) onactivitystarted(com..*****.b) onactivityresumed(com..*****.b) onactivitystopped(com..*****.a) onactivitydestroyed(com..*****.a) onactivitystopped(com..*****.a) 

(something's strange because stopped 2 times while flag flag_activity_clear_top should not re-create new one?)

but when show activity b, launched stopped , destroyed... don't understand why , need activity (re)start. here trace:

onactivitypaused(com.*****.b)         ? why existing b not destroyed ? onactivitydestroyed(com.*****.a) onactivitycreated(com.*****.a) onactivitystarted(com.*****.a) onactivityresumed(com.*****.a) onactivitypaused(com.*****.a) onactivitycreated(com.*****.b) onactivitystarted(com.*****.b) onactivityresumed(com.*****.b) onactivitystopped(com.*****.b)        ?? onactivitydestroyed(com.*****.b)      ?? onactivitystopped(com.*****.a) 

what forget?

edit:

my manifest is:

    <activity         android:name="com.*****.a"         android:configchanges="keyboardhidden|orientation|screensize"         android:label="@string/app_name"         android:theme="@android:style/theme.notitlebar" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:name="com.*****.b"         android:launchmode="singletop" //try line, should keep it?         android:configchanges="keyboardhidden|orientation|screensize"         android:label="@string/app_name"         android:theme="@android:style/theme.notitlebar.fullscreen" >     </activity> 

if use intent.flag_activity_clear_top , have existing instance of target activity in stack, default behaviour clear (finish) activities in stack topmost activity back , including target activity, create new instance of target activity. in case, new intent delivered oncreate() of new instance.

if don't want target activity recreated, need combine intent.flag_activity_clear_top intent.flag_activity_single_top, or need declare target activity launchmode="singletop" in manifest. in case, newintentwill delivered toonnewintent()` of existing instance.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -