p2p获取我的设备的deviceName

p2p获取我的设备的deviceName

本文介绍了如何使用wifi p2p获取我的设备的deviceName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发基于Google的wifi p2p API的应用,我想获取我正在使用的设备的名称(而不是对等设备),但是我发现检索名称的唯一方法是万一我更改了通过使用类似这样的东西:

I'm developing an app based on Google's wifi p2p API and I would like to get the name of the device I'm using (not the peers) but the only way I found to retrieve the name is in case I change it by using something like this:

if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
          // this device details has changed(name, connected, etc)
          mApp.mThisDevice = (WifiP2pDevice) intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE);

          mApp.mDeviceName = mApp.mThisDevice.deviceName;
          PTPLog.d(TAG, "processIntent: WIFI_P2P_THIS_DEVICE_CHANGED_ACTION " + mApp.mThisDevice.deviceName);
          if( mApp.mHomeActivity != null ){
              mApp.mHomeActivity.updateThisDevice(mApp.mThisDevice);
          }
      }

但是我不想(等到更改之前),我想从一开始就知道自己的名字,以便在我打开应用程序时显示出来.这可能吗?

But I don't want that (to wait until a change), I want to know my own name from the beginning, in order to show it when I just open the app. Is this possible?

推荐答案

如果启用了Wi-Fi,并且您注册了P2P和所有加载的内容,则在触发此意图时,设备名称应立即可用.如果禁用了Wi-Fi,则要从WifiP2pManager获取设备名称,必须等待启用.那是我知道如何获得名字的唯一方法.

If Wi-Fi is enabled and you register P2P and everything on load, then the device name should be available right away when that intent fires. If Wi-Fi is disabled, then you would have to wait for it to be enabled if you want to get the device name from WifiP2pManager. That's the only way I know how to get the name.

这篇关于如何使用wifi p2p获取我的设备的deviceName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:06