Android activity launch from search -
my activities:
a - main activity (kind of login screen), finish() on going other activity
b - user content
c = other user content
when go > b > c, press home, launch app launcher, see c stack restored b > c (top) , no problem here
when go > b > c, press home, launch app google search bar on home screen, see a, stack b > c > (top).
question why happening, , how can fix it?
snippet manifest:
<activity android:name="activitya" android:label="@string/app_name" android:launchmode="standard" android:windowsoftinputmode="statehidden|adjustpan" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="activityb" android:label="@string/b_screen_title" > </activity> <activity android:name="activityc" android:label="@string/c_screen_title" android:windowsoftinputmode="statevisible|adjustresize" > </activity>
when use google search bar , select app, launches root activity (in case activitya
). different launcher when launches application (if application running brings existing task foreground). simulate behaviour in app can add following code activitya.oncreate()
:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(); // if not root of task, means activity has been launched // mechanism (ie: google search) if (!istaskroot()) { // isn't root of task, go away quietly , drop user // application wherever left finish(); return; } // ...the rest of oncreate() goes here... }
Comments
Post a Comment