現在、NFC を使用して 2 つのデバイス間でテキストを送信するアプリケーションを作成しています。私は 2 台の Nexus S 携帯電話を持っています。1 台は在庫の Ice Cream Sandwich を実行し、もう 1 台は Gingerbread 2.3.6 を実行しています。
プログラムは、サンプルの Google コードを使用して正しく形成された NDEF メッセージをフォアグラウンドにプッシュし、ピックアップされるのを待ちます。その小さなコード スニペットは次のとおりです。
/**
* Push an NDEF to the foreground with the given text.
* @param message The text to be put in the message that will be pushed.
*
*/
public void pushNDEFwithText(String text)
{
NdefRecord ndefRec = createTextRecord(text, Locale.ENGLISH, true);
NdefMessage message = new NdefMessage(new NdefRecord[]{ ndefRec });
nfcAdapter.enableForegroundNdefPush(this, message);
Log.i("NDEF", "Pushed an NDEF message containing the text: "+text);
}
Gingerbread Nexusにタグをフォアグラウンドにプッシュさせると、プログラムは正常に動作し、ICSはそれを正常に取得し、現在NFCTagInfoを使用して読み取っています。
問題: ICS Nexus でタグを前面に押しても、Gingerbread のタグが認識されないようです。ICS が SNEP を使用し、Gingerbread が NPP を使用しているため、少し問題が発生していると思います。ICS に NPP を強制的に使用させる方法はありますか? または、これが問題ではないと誰かが考えている場合、それは何でしょうか?
注意。理想的には、私は ICS を独占的に使用したかったのですが、Google はバグのために無線での公開を停止しました。また、ICS の更新により Nexus での USB デバッグが壊れたため、インターネット経由でテスト アプリケーションをインストールし、以下を参照してデバッグする必要があります。デバイスのログは理想的ではないため、ジンジャーブレッド用に開発しています。これが、ICS からのログを投稿できない理由でもありますが、NDEF が ICS フォアグラウンドにあり、Gingerbread が受信している (動作していない) ときの Gingerbread を次に示します。
01-30 16:09:59.343: D/NFC JNI(197): Discovered P2P Target
01-30 16:09:59.343: D/NfcService(197): LLCP Activation message
01-30 16:09:59.394: I/NFC JNI(197): LLCP Link activated (LTO=150, MIU=128, OPTION=0x00, WKS=0x01)
01-30 16:09:59.414: D/NdefPushClient(197): LLCP connection up and running
01-30 16:09:59.417: D/NdefPushClient(197): no tags set, bailing
01-30 16:10:00.160: I/NFC JNI(197): LLCP Link deactivated
01-30 16:10:00.160: D/NfcService(197): LLCP Link Deactivated message. Restart polling loop.
01-30 16:10:00.230: D/NFC JNI(197): Discovered P2P Target
01-30 16:10:00.230: D/NfcService(197): LLCP Activation message
01-30 16:10:00.304: I/NFC JNI(197): LLCP Link activated (LTO=150, MIU=128, OPTION=0x00, WKS=0x01)
01-30 16:10:00.320: D/NdefPushClient(197): LLCP connection up and running
01-30 16:10:00.324: D/NdefPushClient(197): no tags set, bailing
01-30 16:10:05.621: I/NFC JNI(197): LLCP Link deactivated
そして、これはジンジャーブレッドのフォアグラウンドにあり、ICS が受信している場所からのものです (これは機能します)。
01-30 16:18:54.058: I/ActivityManager(109): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.terminal/.TerminalActivity bnds=[5,231][115,349] } from pid 200
01-30 16:18:54.093: I/NDEF(1314): Pushed an NDEF message containing the text: This is an example message!
01-30 16:18:54.175: V/RenderScript_jni(200): surfaceDestroyed
01-30 16:18:54.445: I/ActivityManager(109): Displayed com.terminal/.TerminalActivity: +360ms
01-30 16:18:57.015: D/NfcService(197): NFC-EE routing OFF
01-30 16:18:57.023: D/NfcService(197): NFC-C discovery ON
01-30 16:18:57.375: D/NFC JNI(197): Discovered P2P Target
01-30 16:18:57.375: D/NfcService(197): LLCP Activation message
01-30 16:18:57.425: I/NFC JNI(197): LLCP Link activated (LTO=150, MIU=128, OPTION=0x00, WKS=0x01)
01-30 16:18:57.445: D/NdefPushClient(197): LLCP connection up and running
01-30 16:18:57.445: D/NdefPushClient(197): sending foreground
01-30 16:18:57.449: D/NdefPushClient(197): about to create socket
01-30 16:18:57.464: D/NdefPushClient(197): about to connect to service com.android.npp
01-30 16:18:58.398: D/NdefPushClient(197): about to send a 44 byte message
01-30 16:18:58.398: D/NdefPushClient(197): about to send a 44 byte packet
01-30 16:18:58.476: D/NdefPushClient(197): about to close
01-30 16:19:03.812: I/NFC JNI(197): LLCP Link deactivated
01-30 16:19:03.812: D/NfcService(197): LLCP Link Deactivated message. Restart polling loop.