LoginSignup
0
0

More than 1 year has passed since last update.

WifiP2pManagerで他端末を検出する手順

Last updated at Posted at 2021-11-21

WifiP2pManagerで他端末を検出するためには、多くの関数を呼び出す必要があります。(下図)
図1.png

関数だけ抽出すると下表のようになります。

番号 関数 処理内容
1 clearLocalServices 自デバイスのBonjourサービス終了
2 addLocalService 自デバイスのBonjourサービス開始
3 setDnsSdResponseListeners 他デバイスのBonjoourサービス検出時処理、TXTレコード受信時 処理を登録
4 clearServiceRequests 他デバイスのBonjoourサービス検出終了
5 addServiceRequest 他デバイスのBonjoourサービス検出開始
6 discoverPeers デバイス検出
7 discoverServices サービス検出

 番号=3以外の関数は、すべてonSuccessコールバック関数で結果が通知されるようになっており、番号=nの関数のonSuccessコールバック関数で、番号=n+1の関数を呼び出すようになっています。

 6のdiscoverPeersに使われている単語Peersをデバイスと解釈すべきか、サービスと解釈すべきか悩みますが、7のdiscoverServicesでServicesが使われているので、デバイスと解釈すべきか...

参考:
https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager

※WifiP2pManagerとは
 android.net.wifi.p2p.WifiP2pManagerという名前空間の
Androidのアプリケーションフレームワークに含まれるクラス

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0