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.
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.
Open the Settings app to check your device information: Tap About phone. Take note of your device name.
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.
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With