问题
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