问题
My app has several activities, one of which has life in its own right, so I made a shortcut to it in the manifest via:
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Now I have it in the Widgets
zone. This secondary activity now opens when I click the shortcut that I put in my launcher, as I wanted.
However, there is something that does not work as I want: if the main app is working in the background (say, via the home
button), clicking the secondary activity shortcut pop-ups the main app, not the secondary activity.
Why is that? Is this the natural behavior? Is there a way to open the secondary activity always, even side by side with the main app?
Thanks!
L.
回答1:
By surfing other stuff I found the solution of this. Just add
android:launchMode="singleInstance"
in the secondary <activity>
in the manifest. Here is the explanation:
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
来源:https://stackoverflow.com/questions/22799461/why-does-a-shortcut-to-a-secondary-activity-opens-the-main-activity-while-in-the