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?
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.
Try set this properties in manifest for that activity:
android:clearTaskOnLaunch="true"
android:launchMode="singleTop"
Hope it will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.