NFCタグからデータを読み取るための近距離無線通信に取り組んでいます。作成したアプリケーションをテストするためのNFC 対応の Android モバイルと NFC タグがありません。
インテント フィルターを使用してアプリを起動できるかどうかを知りたい(デバイスから NFC タグが検出されたと仮定する必要があります)
私のマニフェストスニペット:
<activity
android:name=".ServerActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="abc.com"
android:pathPrefix="/aaap"
android:scheme="http" />
</intent-filter>
</activity>
私の活動スニペット:
@Override
protected void onNewIntent(Intent intent) {
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
Toast.makeText(getApplicationContext(), "ACTION_TAG_DISCOVERED",
Toast.LENGTH_LONG);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
}