Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to get current device WiFi-direct name

In a P2P setting, I understand how to get another device's name, but how do I get my own device's name? (the one displayed in WiFi-direct under settings).

I have checked WiFiManager, WiFiInfo, and more with no success.

like image 419
Daiwik Daarun Avatar asked Oct 30 '14 02:10

Daiwik Daarun


People also ask

How do I find my Wi-Fi Direct name?

After you turn on wifi on your device, it is send a WIFI_P2P_THIS_DEVICE_CHANGED_ACTION broadcast. You can catch this with a broadcast receiver and you can get a WifiP2pDevice object, that is your device. You will get this call when you register for the WifiP2pBroadcastReceiver, it doesn't matter if wifi is already on.

How do I find my android device name?

Open the Settings app to check your device information: Tap About phone. Take note of your device name.

Where do I find Wi-Fi Direct on Android?

To check the status of Wi-Fi Direct on your device, go into Settings -> Network & internet -> Wi-Fi -> Wi-Fi preferences and then tap Wi-Fi Direct. Your smartphone will start scanning for devices that you can connect to. Unlike with Bluetooth, there is no button or anything that you need to tap to turn Wi-Fi Direct on.

How do I change my Wi-Fi Direct name?

To change the Wi-Fi Direct network name, select Change Network Name and select Yes. Select Change, then use the on-screen keyboard to enter the new network name. To change the Wi-Fi Direct password, select Change Password and select Yes. Use the on-screen keyboard to enter your new Wi-Fi Direct password.


1 Answers

After you turn on wifi on your device, it is send a WIFI_P2P_THIS_DEVICE_CHANGED_ACTION broadcast. You can catch this with a broadcast receiver and you can get a WifiP2pDevice object, that is your device.

 @Override
 public void onReceive(Context context, Intent intent) {
     WifiP2pDevice device = intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE);
     String thisDeviceName = device.deviceName;
 }
like image 58
László Magyar Avatar answered Nov 16 '22 02:11

László Magyar