Creating P2P Connections with Wi-Fi on Android

放肆的年华 提交于 2019-12-11 22:36:57

问题


So I'm trying to create p2p connection work on android. And I am stuck on following part. code below is what's provided on API and it does not make sense to me. I feel like there must be a type for a mManager and the type is not given. How do I make this Work?

Link to API: http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

@Override
Channel mChannel;
public void onCreate(Bundle savedInstanceState) {
    ....
    mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);

    mChannel = mManager.initialize(this, getMainLooper(), null);
}

回答1:


I have a feeling you imported the wrong Channel. You may have imported

java.nio.Channels.Channel

when the one you want is

android.net.wifi.p2p.WifiP2pManager.Channel

hope this helps.




回答2:


I used alljoin in my project. This api very successfully communicate two devices.




回答3:


The type you are looking for is:

WifiP2pManager manager;


来源:https://stackoverflow.com/questions/19239721/creating-p2p-connections-with-wi-fi-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!