最終更新:
moonlight_aska 2012年09月16日(日) 22:49:24履歴
NFCカード/タグが対応しているNFC規格の情報を取得するには, タグ(Tag)クラスを利用する.



- Nfc03.java
- Intent#getIntentメソッドで, Intentのインスタンスを取得する.
- インテントのアクションが, "ACTION_TECH_DISCOVERED"かチェックする.
- Intent#getByteArrayExtraメソッドに, NfcAdapter.EXTRA_TAG指定して, Tagのインスタンスを取得する.
- Tag#getTechListメソッドで, 対応しているNFC規格の情報を取得する.
package com.moonlight_aska.android.nfc03;
import android.app.Activity;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.widget.TextView;
public class Nfc03 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_nfc03);
TextView text = (TextView)findViewById(R.id.tag_id);
// インテントの取得
Intent intent = getIntent();
// ICカードの検出かチェック
String action = intent.getAction();
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
// NFC対応情報の取得
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String [] techList = tag.getTechList();
String str = "";
for (String tech : techList) {
str += tech + "\n";
}
text.setText(tagId);
}
}
}
- res/xml/filter_nfc.xml
- AndroidManifest.xml
- NFC規格の種類
- android.nfc.tech.IsoDep
- android.nfc.tech.NfcA
- android.nfc.tech.NfcB
- android.nfc.tech.NfcF
- android.nfc.tech.NfcV
- android.nfc.tech.Ndef
- android.nfc.tech.NdefFormatable
- android.nfc.tech.MifareClassic
- android.nfc.tech.MifareUltralight
- 動作例
- NFC-A (MIFARE)

- NFC-B

- NFC-F

コメントをかく