Get Bluetooth local mac address in Marshmallow
As it turns out, I ended up not getting the MAC address from Android. The bluetooth device ended up providing the Android device MAC address, which was stored and then used when needed. Yeah it seems a little funky but on the project I was on, the bluetooth device software was also being developed and this turned out to be the best way to deal with the situation.
Android get bluetooth address in marshmallow
Access to the mac address has been deliberately removed:
http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
use this code :
get the mac address via reflection or Settings.Secure:
String macAddress = android.provider.Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");
How to get bluetooth device mac address by stored device name
I think it's impossible.You can't get the mac address only from a known device name.The bluetooth device name is not the key element for the bluetooth connection and communication,but the mac address will be.Only you can get the mac address according to the device name if you has pre-stored the related BluetoothDevice object and the name is different from the others.
Getting Mac Address on Marshmallow In Xamarin
Try using this code:
public string GetMacAdress(Context context)
{
string mac = GetMacAddressLegacy(context);
if (mac == "02:00:00:00:00:00")
{
var interfaces = Java.Net.NetworkInterface.NetworkInterfaces;
foreach (var nif in interfaces)
{
if (!nif.Name.ToLower().Contains("wlan")) continue;
byte[] macBytes = nif.GetHardwareAddress();
string macString = BitConverter.ToString(macBytes);
if (!string.IsNullOrWhiteSpace(macString))
mac = macString.Trim().ToUpper().Replace("-", ":");
}
}
return mac;
}
Related Topics
How to Detect Android CPU Speed
Retrieve Contact Phone Number from Uri in Android
How to Change Images on Imageview After Some Interval
What Are the Ipc Mechanisms Available in the Android Os
Background Service Getting Killed in Android
Manually Adding Aar with Dependency Pom/Iml File
Post on Facebook Wall Using Facebook Android Sdk Without Opening Dialog Box
Align Top of Image to Top of Textview
App Getting Stuck with E/Com.Facebook.Internal.Attributionidentifiers
Firebase Sort by Points Depending on Date
How to Create and Save a Screenshot from a Surfaceview
Implement Double Click for Button in Android
Using the "Animated Circle" in an Imageview While Loading Stuff
Debugging with Android Studio Stuck at "Waiting for Debugger" Forever