简体   繁体   中英

Android Bluetooth Device List - Friendly Names

(Cross posted from https://forums.xamarin.com/discussion/116840/android-bluetooth-device-list-friendly-names )

I have this C# method for Android to get a list of paired Bluetooth devices:

public List<string> PairedDevices()
{
    var adapter = BluetoothAdapter.DefaultAdapter;
    var devices = new List<string>();

    foreach (var bd in adapter.BondedDevices)
    {
        devices.Add(bd.Name);
    }

    return devices;
}

Which works fine, except I need the list to show the same name as what shows on the list of devices that is displayed to users in the Android Bluetooth settings. If the user has renamed a device , the new name is not listed in the "Name" property. Name still contains the original name of the device before the user renamed it.

I'm new to Android development. I'm seeing some references to ExtraDevice and ExtraName but am not sure if this is what I need or how to obtain it. Help?

PS: am using a Xamarin Forms PCL solution, and the above method is part of a Dependency class borrowed from here: https://acaliaro.wordpress.com/2017/02/07/connect-a-barcode-reader-to-a-xamarin-forms-app-via-bluetooth/ .

@Salman-Nasseem basically answered this in their comment. It turns out my question is misguided. If the user renamed a bluetooth device, the actual device name has not changed.

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