android - App restarting on play store open click -
<activity android:name=".activity.landingpage.landingpageactivity" android:label="@string/app_name" android:launchmode="singletop" android:screenorientation="portrait" android:theme="@style/apptheme.noactionbar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> so simple. when open app launcher icon, opens.i go , click on launcher app icon again brings application front again since open.however, if go play store , click open there app has 2 instances open. if want example how working, facebook has same issue .also app fotmob has same issue think.
i had same issue. put below code launcher activity.
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (!istaskroot() && getintent().hascategory(intent.category_launcher) && intent.action_main.equals(getintent().getaction())) { finish(); return; } //other code } problem:
suppose have task stack [a -> b -> c] , root activity, when launch application play store task stack become(system clears top of root) [a] if have finished root activity stack like(system create new instance of root activity , place top of existing task) [b -> c -> a].
why?
because play store launch app category=launcher, action=main, flag = activity_new_task, flag = activity_brought_to_front
solution
take case have removed root activity , stack [b -> c], when try open app play store stack become [b -> c -> a]
now, not in root of stack , has category = launcher , action = main so, can remove using finish() , stack remain same [b -> c]
*note: tested on android 7.0
Comments
Post a Comment