トラッキング コード

8/20/2011

Using NFC part 1

I try to develop simple NFC application.

Describe the parameters needed to AndroidManifest.xml

Add the necessary permissions to use an NFC Hardware.

1
2
<uses-permission android:name="android.permission.NFC">
</uses-permission>


When up to AndroidMarket, uses the terminal to be visible only to add the feature NFC-featured.

1
2
<uses-feature android:name="android.hardware.nfc" android:required="true">
</uses-feature>


If you want to handle the NFC tag in Activity, add intent-filter.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED">
  <data android:mimetype="mime/type">
</data></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">
</meta-data>

You should describe only necessary .
is a tag which is using in android.nfc.action.TECH_DISCOVERED.
and add 'nfc_tech_filter.xml' in yout project, that you want to receive NFC tag in your Activity.
For details, see http://developer.android.com/intl/ja/guide/topics/nfc/index.html#dispatch

1
2
3
4
5
6
7
8
9
10
11
12
13
<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>

You should describe only necessary .
XXX is class name in '/frameworks/base/core/java/android/nfc/tech'.

No comments:

Post a Comment