- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 wifip2p
manager
将文件从一台设备发送到另一台设备。始终同一设备成为客户端,或者换句话说,其他设备始终保持组所有者状态,并始终接收数据
。
我尝试了下面的代码来发送和接收数据
。
void onConnectionInfoAvailable(WifiP2pInfo info) {
this.info = info;
this.getView().setVisibility(View.VISIBLE);
// The owner IP is now known.
TextView view = (TextView) mContentView.findViewById(R.id.group_owner);
view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no)));
// InetAddress from WifiP2pInfo struct.
view = (TextView) mContentView.findViewById(R.id.device_info);
view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress());
// After the group negotiation, we assign the group owner as the file
// server. The file server is single threaded, single connection server
// socket.
if (info.groupFormed && info.isGroupOwner) {
new FileServerAsyncTask(getActivity(), mContentView.findViewById(R.id.status_text)).execute();
} else if (info.groupFormed) {
// The other device acts as the client. In this case, we enable the
// get file button.
mContentView.findViewById(R.id.btn_start_client).setVisibility(View.VISIBLE);
((TextView) mContentView.findViewById(R.id.status_text)).setText(getResources().getString(R.string.client_text));
}
// hide the connect button
mContentView.findViewById(R.id.btn_connect).setVisibility(View.GONE);
}
最佳答案
这些是您需要检查如何实现解决方案的资源:
https://android.googlesource.com/platform/development/+/master/samples/WiFiDirectDemo
请记住:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
(需要许可才能找到附近的同行)
https://developer.android.com/reference/android/net/wifi/WpsInfo.html#PBC
WpsInfo.PBC
仅在 api 28 之后被弃用,因此您需要将其设置为 WifiP2pConfig 实例才能连接到 channel
关于java - 如果按下连接按钮,如何创 build 备客户端或发送者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57626653/
我正在尝试将 tslib 嵌入到 ARM 系统中,以便使用触摸屏设备;我已经成功安装了它,但不幸的是我无法检索所有笔记来再次安装它。 x) 我交叉编译了库文件,并将它们放入 /usr/lib ;我已经
我正在尝试开发 Linux 设备驱动程序,作为我的第一次尝试,我正在尝试开发具有以下文件选项的字符设备驱动程序, struct file_operations fops{ .open=open_fu
我们在 IoT Agent Ultralight 中发现了一个错误。 如果我们尝试向不存在的设备发送测量值,我们将收到 404 - DEVICE_NOT_FOUND 错误,但同时将在 IoTA 和 O
我有一个 d3dDevice: ComPtrd3dDevice; 我在这里将它用于 dxgiDevice: ComPtr dxgiDevice2; HRESULT hr; hr
我正在尝试开发 Linux 设备驱动程序,作为我的第一次尝试,我正在尝试开发具有以下文件选项的字符设备驱动程序, struct file_operations fops{ .open=open_fu
我在安装了 Xcode 4.5.1 的 Mt Lion 上运行。 默认情况下,当我构建并部署到 iOS 5.1 设备时,显示会在我旋转设备时旋转,但当我部署到 iOS 6 模拟器或运行 iOS 的 i
我在 Vagrantfile 中使用以下行创建了一个 hostonly 网络 config.vm.network :hostonly, "10.1.1.15" 我可以看到它设置了/etc/networ
我在 Vagrantfile 中使用以下行创建了一个 hostonly 网络 config.vm.network :hostonly, "10.1.1.15" 我可以看到它设置了/etc/networ
当我在应用程序中添加设备时,我想在 IoT 中心创建一个设备。 我正在寻找可用于执行操作的 REST 端点。或任何可用于执行此操作的 SDK。 最佳答案 查看以下文档: Service - Creat
我一生都无法使用 xcode 组织者“自动设备配置”中的“团队配置配置文件”在 xcode 4.0.1 中将我的应用程序构建到我的 iPad 上。 该应用程序完美地构建到模拟器,但当我构建到 iPad
我是一名优秀的程序员,十分优秀!