我将 AAR 保存在我的 NFC-Tag 上。如果我用 Nexus S (Android 4.1.1) 扫描 TAG,我会得到 NfcAdapter.ACTION_NDEF_DISCOVERED 并且 NFCReaderActivity 直接启动。
如果我对 HTC X (Android 4.0.3) 执行相同操作,则应用程序会启动,但我只获得了 android.intent.action.MAIN,因此 NFCReaderActivity 不会出现,并且标签也不会被扫描。
这适用于三星 Nexus S,但不适用于 HTC:
<activity android:name=".activities.NFCWriterActivity"></activity>
<activity android:name=".activities.NFCReaderActivity">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".activities.NFCBeamActivity">
</activity>
<activity android:name=".activities.WifiManagerActivity"></activity>
<activity android:name=".activities.WifiConfiguratorActivity"></activity>
<activity android:name=".activities.TagWriterOptionsActivity"></activity>
<activity android:name=".activities.WifiScannerTagActivity"></activity>
<activity android:name=".activities.WifiScannerActivity"></activity>
<activity android:name=".activities.WifiListActivity">
</activity>
这是我的活动和过滤器。
有人出主意吗?
编辑:
这适用于 HTC,但不适用于三星 Nexus S:
<activity android:name=".activities.NFCWriterActivity"></activity>
<activity android:name=".activities.NFCReaderActivity">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/vnd.wfa.wsc" />
</intent-filter>
</activity>
<activity android:name=".activities.NFCBeamActivity">
</activity>
<activity android:name=".activities.WifiManagerActivity"></activity>
<activity android:name=".activities.WifiConfiguratorActivity"></activity>
<activity android:name=".activities.TagWriterOptionsActivity"></activity>
<activity android:name=".activities.WifiScannerTagActivity"></activity>
<activity android:name=".activities.WifiScannerActivity"></activity>
<activity android:name=".activities.WifiListActivity"></activity>
在这里我得到以下异常@HTC - 也许这是我不知道的问题:堆栈:
D/AudioTrack( 3938): stop 0x1601940
D/AudioFlinger( 142): releasing 231 from 3938
D/AudioTrack( 3938): AudioTrack destructor X
D/power ( 277): Already locked performance.
W/CpuWake ( 277): >>acquireCpuPerfWakeLock!
W/CpuWake ( 277): <<acquireCpuPerfWakeLock!
E/ActivityManager( 277): startLaunchActivity get appname failed
E/ActivityManager( 277): java.lang.NullPointerException
E/ActivityManager( 277): at com.android.server.am.ActivityStack.startLaunchActivity(ActivityStack.java:4831)
E/ActivityManager( 277): at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3352)
E/ActivityManager( 277): at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2509)
E/ActivityManager( 277): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:131)
E/ActivityManager( 277): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1751)
E/ActivityManager( 277): at android.os.Binder.execTransact(Binder.java:338)
E/ActivityManager( 277): at dalvik.system.NativeStart.run(Native Method)
I/ActivityManager( 277): START {act=android.nfc.action.NDEF_DISCOVERED typ=application/vnd.wfa.wsc pkg=at.nfc.wifi (has extras)} from pid 3938
W/ActivityManager( 277): Duplicate finish request for ActivityRecord{41163a90 com.android.nfc/.NfcRootActivity}
D/power ( 277): Already locked performance.
I/Intent ( 277): @test_code: getHtcIntentFlag: 0 obj: 1094379848
W/CpuWake ( 277): >>acquireCpuPerfWakeLock!
W/CpuWake ( 277): <<acquireCpuPerfWakeLock!
也许问题是版本 4.1.1 vs 4.0.3 - 我不知道:事实是:只有 Ndef 适用于三星,如果我添加