在Android上使用Wi-Fi创建P2P连接 [英] Creating P2P Connections with Wi-Fi on Android

查看:781
本文介绍了在Android上使用Wi-Fi创建P2P连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试在android上创建p2p连接工作. 我被困在下面的部分.下面的代码是API上提供的,对我来说这没有意义.我觉得mManager必须有一个类型,而没有给出类型. 我该如何进行这项工作?

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?

链接到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);
}

推荐答案

我感觉您导入了错误的Channel.您可能已导入

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

java.nio.Channels.Channel

当你想要一个的时候

android.net.wifi.p2p.WifiP2pManager.Channel

希望这会有所帮助.

这篇关于在Android上使用Wi-Fi创建P2P连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆