0

2台のNexusSデバイスで、個々のメッセージごとに電話をタップすることなく、双方向でNdefメッセージを交換できるようにしようとしています。動作が予測できない可能性があるため、両方のデバイスのフォアグラウンドプッシュとディスパッチを有効にすることは良い考えではないと思います。これを達成する1つの方法は、イニシエーターが

  1. fgプッシュとfgディスパッチを無効にする
  2. Ndefメッセージを設定する
  3. メッセージでfgpushを有効にする
  4. メッセージ送信後にfgプッシュを無効にする
  5. fgディスパッチを有効にする
  6. インテントを介して応答を受信する
  7. fgディスパッチを無効にする
  8. 後藤2

同様に、レスポンダーについても同様です。

唯一のことは、現在のAPIがステップ4をサポートしていないように見えることです。つまり、メッセージが正常にプッシュされたときに通知を受け取ります。誰かがそれをどのように行うことができるかを提案できますか?または、シングルタップP2Pを実現する別の方法はありますか?

乾杯。

4

1 に答える 1

0

It can be done without the NFC service having to notify message push. Let your application implicitly infer from the response message. Isn't that what you want, the message reaching the peer, and just not pushed over NFC to a device that doesn't understand your message.

  1. Enable Foreground push message with your NDEF message only from the initiator, also enable Foreground dispatch
  2. Receive the response NDEF message from peer
  3. Create new response NDEF message and enable it in foreground push, to continue the next cycle of message exchange
  4. Disable Foreground push/Foreground dispatch to terminate communication.

    Additionally you can have NDEF_DISCOVERED filter for the initial trigger (at the receiver), then let the Foreground dispatch take over for subsequent messages.

Hope it helps !!

于 2011-05-06T04:50:07.470 に答える