Reputation: 209
I used the NFC tag for application launching.but when other activities are running and i touch the tag to device the NFC application is launching again.
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testnfc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.testnfc.TestNFCActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.test.testnfc.NFCLoginActivity"
android:label="@string/app_name"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.test.testnfc.FirstActivity" >
</activity>
<activity android:name="com.test.testnfc.SecondActivity" >
</activity>
<activity android:name="com.test.testnfc.ThirdActivity" >
</activity>
<activity android:name="com.test.testnfc.FourthActivity" >
</activity>
<activity android:name="com.test.testnfc.FifthActivity" >
</activity>
</application>
</manifest>
I don't want this.Instead it should stay in the same activity. Any idea about this?
Upvotes: 0
Views: 1025
Reputation: 1004
Try set this properties in manifest for that activity:
android:clearTaskOnLaunch="true"
android:launchMode="singleTop"
Hope it will help.
Upvotes: 0
Reputation: 82553
Move the intent-filter for NFC detection into a Service, so that when a tag is discovered a Service is started instead of an Activity.
You can then use the Service to decide what you want to do and which Activity to launch.
Upvotes: 2