如何註冊我的APP是NFC程式呢?
1. 首先要先開起 AndroidManifest.xml
<activity android:configchanges="locale" android:label="@string/app_name" android:name=".MyNfc" android:screenorientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN">
<category android:name="android.intent.category.LAUNCHER">
</category></action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED">
</action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED">
</action></intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter.xml">
</meta-data>
</activity>
2. 在此 xml 要去 permission 把NFC權限開啓
nfc_per.xml 定義這隻程式可以接受TAG的規格
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.NfcB</tech>
<tech>android.nfc.tech.NfcF</tech>
<tech>android.nfc.tech.NfcV</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.MifareClassic</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
</resources>
沒有留言:
張貼留言