android - Custom TaskStack finishes parent activity from notification -


i'm having problems using taskstack notifications. i'm trying keep navigational flow of app when notification tapped.

the navigation style of app like:

principalactivity (parent) → secondaryactivity (child)

sometimes gcm service can push notifications starts secondaryactivity. instance of principalactivity may or not exist implement custom pendingintent taskstack (see below). works when principalactivity paused or closed.

the problem comes when user clicks on notification while principalactivity in foreground: pendingintent calls principalactivity.ondestroy() , creates new stack of activities losing data.

service pushes notification:

intent notificationintent = new intent(context, secondaryactivity.class);  taskstackbuilder stackbuilder = taskstackbuilder.create(this); stackbuilder.addparentstack(secondaryactivity.class); stackbuilder.addnextintent(notificationintent);  pendingintent pendingintent = stackbuilder.getpendingintent(0,         pendingintent.flag_update_current); mnotifybuilder.setcontentintent(pendingintent);  mnotificationmanager.notify(id, mnotifybuilder.build()); 

androidmanifest.xml

<activity     android:name="com.hitsbam.geotalk.principal"     android:configchanges="orientation|screensize|keyboardhidden"     android:label="@string/principal_titulo"     android:launchmode="singletask" />  <activity     android:name="com.hitsbam.geotalk.secondary"     android:configchanges="orientation|screensize|keyboardhidden"     android:label="@string/peticiones_titulo"     android:parentactivityname=".principal" /> 

i tried flags of pendingintent (flag_update_current, flag_one_shot) , experimented different launch_mode activities in manifest (singletask, singletop, singleinstance), no luck.

how can create aforementioned custom taskstack activity , parents when parent in foreground, , without losing data? (ideally, reusing activity in stack?)


Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -