简体   繁体   中英

How to rename Android bluetooth paired device by programmly?

I need to "rename" bluetooth paired device of Android phone with programming. But searching results are most discuss about local bluetooth rename method. And it could use setname() to complete. Does there have any method to rename "paired device" of Android phone ?

I know the question is old, but I just needed this and found out how to do it. It uses reflexion so I'm not sure this is the best way to go but it works.

public void renamePairDevice(BluetoothDevice device, String name) 
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
    Method m = device.getClass().getMethod("setAlias", String.class);
    m.invoke(device, name);
}

I don't think you can rename the name of the paired device. You can only change the name from the paired device's settings.

Think of it like a wifi router, you cannot change the name of the router, but you can only connect to it.

However if you want,you could assign this way

Set<BluetoothDevice> devices = btAdapter.getBondedDevices();
    if (devices.size() > 0) {
         for(int i=0;i<device.size();i++) {
            mDevice[i] = device;
            bondedDevices.add(mDevice.getName());


        }
    }

That way you could get the name of the paired Devices as a mDevice array. Hope it solved your issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM