- How to get name of the connected Bluetooth device on android
- 2 Answers 2
- How to Change Device Name on Android (WiFi and Bluetooth)
- Change Device Name on Android
- Change Device Name via ADB Command
- Changing WiFi Hotspot Name
- Change Bluetooth Name on Android
- Changing Wi-Fi Direct Name
- Change Device Name on Google Play Store
How to get name of the connected Bluetooth device on android
I can get information about the device that is previously paired and trying to make a connection or a device trying to pair to the device. what I want is the name or the connection state of the currently paired and connected device.
2 Answers 2
String name; String address; String threadName; public void checkConnected() < BluetoothAdapter.getDefaultAdapter().getProfileProxy(this, serviceListener, BluetoothProfile.HEADSET); >private BluetoothProfile.ServiceListener serviceListener = new BluetoothProfile.ServiceListener() < @Override public void onServiceDisconnected(int profile) < >@Override public void onServiceConnected(int profile, BluetoothProfile proxy) < for (BluetoothDevice device : proxy.getConnectedDevices()) < name = device.getName(); address = device.getAddress(); threadName = Thread.currentThread().getName(); Toast.makeText(MainActivity.this, name+" " + address+ threadName, Toast.LENGTH_SHORT).show(); txtName.setText(name + " " + address); Log.i("onServiceConnected", "|" + device.getName() + " | " + device.getAddress() + " | " + proxy.getConnectionState(device) + "(connected = " + BluetoothProfile.STATE_CONNECTED + ")"); >BluetoothAdapter.getDefaultAdapter().closeProfileProxy(profile, proxy); > >;
BluetoothServerSocket bluetoothServerSocket = bluetoothAdapter.listenUsingRfcommWithServiceRecord("abc", uuid); BluetoothSocket bluetoothSocket = bluetoothServerSocket.accept(); BluetoothDevice device = bluetoothSocket.getRemoteDevice(); String deviceName = device.getName();
looks like the code stock when it get to this line BluetoothSocket bluetoothSocket = bluetoothServerSocket.accept();
Have you checked the documentation? developer.android.com/guide/topics/connectivity/… Check out the sections «Querying paired devices» and «Discovering devices». Especially the call to device.getName()
Thanks for your reply. But what I want is to get the connection status of the currently paired and connected Bluetooth device . No the ones that are trying to connect. For that situation I preferred to use broadcast Listers
And about the link you mentioned, BluetoothDevice class doesn’t provide a function to make a query of paired devices connection state
How to Change Device Name on Android (WiFi and Bluetooth)
Your Android device’s name works as a hostname while connecting to other devices via WiFi. A personalized device name for WiFi, Hotspot, or Bluetooth connection makes it easy to recognize a device in the list of other connected devices. By default, all Android devices come with a generic name and so it’s a good idea to give your device a unique name. Here is how to change the device name on Android for wired and wireless connections. Moreover, we’ll also see how we can change the device name in the Google Play Store.
Before you proceed, however, please check out my handy tutorial describing all the possible methods to find the codename of an Android device.
Personally, I prefer to see a personalized name for all my devices whether it be my PC, laptop, smartphone, or WiFi router. If you own an Android smartphone or a tablet device, follow the instructions below to change the following:
- Android device name
- Bluetooth name
- WiFi Direct name
- Mobile hotspot name
- Device name in the Play Store
Changing the device name automatically changes the names for Bluetooth and WiFi Hotspot connections. However, it’s possible to set one name for your Android device and a different Bluetooth name and hotspot name. Having given a custom name to your device, you can easily recognize your device in the list of available wireless networks and Bluetooth devices. Thankfully, changing the device name is not as complicated as turning off Talkback on Android devices.
Change Device Name on Android
If you want to personalize the device name of your Android phone or tablet, the easiest way is to do it via Settings.
- Open the Settings app on your Android device.
- Scroll down to About phone or About device and tap on it.
- Now tap on the Device name option.
- Type the desired name and select OK.
If you own a Samsung Galaxy phone or Tab, the steps to change the device name are almost the same.
Go to Settings > About phone and tap on the Edit button. Type the device name you want and tap on Done.
It doesn’t matter whether you own a device from OnePlus, Realme, Oppo, Vivo, Nokia, Lenovo, Huawei, etc., you just need to navigate to Settings > About phone > Device name, tap on the current device name, and assign a name. Once you change the name using the method given above, it’ll show the custom name for all wired and wireless connections.
Android device names on Samsung TV
Android device name on Windows PC
Change Device Name via ADB Command
While changing the Android device name via Settings is very easy, there’s still another way you should try. You must be familiar with ADB commands and you can change your Android phone’s name using ADB as instructed below.
- Download the latest Android SDK Platform-tools and set them up on your computer.
- Install the latest Android USB driver on your computer.
- Open the platform-tools folder and launch the command prompt window. There are 2 ways to do that.
- Place the mouse pointer at an empty place in the folder window, right-click on the mouse, and select the Open PowerShell window here option.
- Just type “cmd” in the folder window address bar and hit the Enter key.
adb devices
adb shell settings get global device_name
adb shell settings put global device_name "Galaxy Note 10+ Technastic"
- The screenshot attached below will help you understand all the steps clearly.
- Now, navigate to Settings > About phone and you’ll find that the device name has been changed.
Here is a huge list of ADB Shell commands that you must check out to learn more.
Changing WiFi Hotspot Name
Usually, I use my Android phone’s hotspot to binge-watch Netflix and Prime Video shows on my Smart TV and surf the web on my laptop during commutes. It’s a good idea to give a device a personalized name for convenience. In case you just want to change the hotspot name of your Android device, below are the steps.
- Open Settings on your Android phone.
- Samsung Galaxy devices: Tap on Connections >Mobile Hotspot and Tethering.
- OnePlus phones: Tap on Mobile/Wi-Fi Hotspot and Tethering.
- Xiaomi Redmi phones: Tap on Portable Hotspot under SIM cards and mobile networks.
- To change the hotspot name on Android devices from different OEMs follow the steps below.
- Samsung devices: You need to enable the mobile hotspot before you can change its settings. Tap on Mobile Hotspot and Tethering as shown below. Tap on the current device name and rename it. Select the Save option.
Hotspot name on Xiaomi and Redmi
Hotspot name on OnePlus phones
Change Bluetooth Name on Android
As I mentioned above, you can set different device names for Bluetooth and WiFi connections while keeping a different device name on Android. Below is how you can change the Bluetooth name for an Android device.
Note: You must turn on Bluetooth on your device before you can edit its settings.
- Open the Settings app on your Android device.
- Tap on Bluetooth and turn it on. Alternatively, you can open the Quick Settings panel by sliding down the status bar and tapping and holding the Bluetooth icon.
- Tap on the Device name and type the Bluetooth name for your device.
- If you own a OnePlus phone, you need to select Pair new device to access the Device name option.
- On Samsung Galaxy devices, you don’t have the option to change the Bluetooth name. Samsung devices automatically take your device name as the Bluetooth name.
Changing Wi-Fi Direct Name
Wi-Fi Direct is a faster way than Bluetooth for sharing files over a wireless network. If you want to set the Wi-Fi Direct name for your device, here’s how to do it.
- Turn on the WiFi on your device first.
- Open Android Settings on your device and tap on Wi-Fi.
- Now do as described below.
- Xiaomi phones: Select Additional settings and tap on Wi-Fi Direct. You need to tap on Device name and enter the name you want.
Change Device Name on Google Play Store
Every Android phone has the Google Play Store apps installed out of the box. All Android devices registered with the same Gmail ID are shown on your Google account dashboard.
If you want your Google Play Store and Google Dashboard to show a personalized name for your Android devices, follow the steps given below.
- Open the Google Play Store settings page on your desktop or mobile browser.
- You’ll see the list of your devices.
- Tap or click on the Edit button in front of the device name and rename the device.
- After that, tap on the Update icon.
That’s it! You have successfully changed the device name for your Android phone. Next time you try to install an app from the Google Play Store (web), you’ll be asked to choose a device with the name you assigned.
It’s time to wind up my tutorial here. I hope now you’ll be able to change not only the device name on your Android but also the Bluetooth name, Hotspot name, and WiFi Direct name. In case you still have any questions, please drop us a comment.