Issue
I have two intent filters for the root activity of my application
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<data android:mimeType="application/com.example.package" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
One filter is for launching the application from the launcher icon, the other is to launch the activity when the user touches an NFC tag.
I want that when user presses the HOME button from any activity in the application, the next time he presses the launcher icon or touches NFC tag, the application must resume (as it is the case with every application).
But this is what is happening: When user taps the NFC tag, the first activity is launched. Then he navigates onto further activities. Presses HOME. Taps the NFC tag again, the first activity (MyActivity) is launched, and the previous stack is cleared.
On the other hand, When the user selects the launcher icon, navigates onto further activities, presses HOME, and then presses the the launcher icon again, MyActivity is started as a new activity on top of the stack. (now there are two MyActivities in the stack).
Solution
You need to define the way your activity launches.
If you want your activity to always launch on the same task use: android:alwaysRetainTaskState="true"
and android:taskAffinity="your.task.name"
Also take a look on android:launchMode="singleTop"
and android:launchMode="singleTask"
for further control on how the activity is launched.
Answered By - Inon Stelman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.