My cordova application not launching after NFC tag detect

后端 未结 2 486
天命终不由人
天命终不由人 2021-01-23 04:19

I am using Apache cordova to build android applications. I made an application with NFC feature.

we already written data into NFC tag, with

相关标签:
2条回答
  • 2021-01-23 04:51

    In order to receive an NFC intent together with the whole NDEF message in your app, you would need to define a proper intent filter that matches the first record in the above NDEF message:

    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <action android:name="android.nfc.action.TAG_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    

    Refer how to handle NFC

    0 讨论(0)
  • 2021-01-23 05:05

    As SweetWisher wrote, you need to define a proper action for your intent filter (android.nfc.action.NDEF_DISCOVERED( in your case. In addition, you should be aware that MIME types used in the NDEF_DISCOVERED intent filter must always be all-lower-case. The reason is that MIME types are case-insensitive as per the RFC but Android's intent filter matching is case-sensitive. Consequently, Android will convert MIME types to all-lower-case before matching in order to overcome case-sensitivity issues (see this answer for a more detailed explaination).

    As a result, you intent filter would look something like this:

    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="myapp/firstnfcapp" />
    </intent-filter>
    
    0 讨论(0)
提交回复
热议问题