私はNFCベースのAndroidアプリケーションで数ヶ月働いています。これは、 Android NFCドキュメントで説明されているように、NFCタグを読み書きできます。(NFC APIに関するかなり良いドキュメント)。いくつかの例に従う必要があるとき、私はNFCDemoアプリで遊んでいます。
これが私の現在のXMLマニフェストです。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package"
android:versionCode="1"
android:versionName="1.0.0">
<uses-sdk android:minSdkVersion="10" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:launchMode="singleTask">
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<!-- the following actions and categories let the App be in Android Action Chooser and also Scan Tags when the app si running -->
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <!-- Main application -->
<category android:name="android.intent.category.LAUNCHER" /><!-- Logo Display in App List-->
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
</activity>
<activity android:name=".RouteActivity">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="www.my.custom.tag.com" android:scheme="http" />
</intent-filter>
</activity>
</application>
</manifest>
tech_filterファイルの定義は次のとおりです。
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.MifareUltralight</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.MifareClassic</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.MifareUltralight</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcV</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcF</tech>
</tech-list>
</resources>
フォアグラウンドディスパッチシステムも構成しました:
public void setUpForegroundDispatchSystem(Activity activity) {
this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
this.pendingIntent = PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
this.intentFiltersArray = new IntentFilter[] { ndef };
this.techListsArray = new String[][] {
new String[] { MifareUltralight.class.getName(),
Ndef.class.getName(), NfcA.class.getName() },
new String[] { MifareClassic.class.getName(),
Ndef.class.getName(), NfcA.class.getName() },
new String[] { MifareUltralight.class.getName(),
NdefFormatable.class.getName(), NfcA.class.getName() },
new String[] { Ndef.class.getName(), NfcV.class.getName() },
new String[] { NfcF.class.getName() }};
}
しかし今、私は私のAndroidアプリケーションにp2p機能を追加したいと思います。そのため、アプリが既にインストールされている他の電話にタグをプッシュすると、Androidアクションチューザーがアプリで起動されるようになります。また、私のアプリがすでに実行されている場合は、p2pリクエストを処理する必要があります。 Androidのドキュメントを使用してp2pタグを正しくプッシュすることはできますが、このタグを処理できるアプリは、携帯電話にすでにいくつかのNFCアプリがインストールされているにもかかわらず、Googleのもの(Nexus Sで使用されるタグアプリケーション)のみです。 。何か案は?それについての有用なドキュメントはありますか?