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);
}
有帮助吗?

解决方案

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.

其他提示

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

The type you are looking for is:

WifiP2pManager manager;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top