I'm trying to start a activity when my smartphone scans an NDEF message. This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidbeam"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.androidbeam.MainActivity"
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.example.androidbeam.SendTextActivity" >
</activity>
<activity android:name="com.example.androidbeam.ReceiverNDEFActivity" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="ext"
android:pathPrefix="/com.example:externalType"
android:scheme="vnd.android.nfc" />
</intent-filter>
</activity>
</application>
</manifest>
Whenever I scan my NDEF message, my main activity launches but I'd like my ReceiverNDEFActivity to launch. I'm not sure why this is the case.
This is my NdefMessage:
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
byte[] payload= new String("Hello");
String domain = "com.example";
String type = "externalType";
NdefRecord extRecord = NdefRecord.createExternal(domain, type, payload);
NdefMessage msg = new NdefMessage(new NdefRecord[] { extRecord });
return msg;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…