Get Bluetooth local mac address in Marshmallow

前端 未结 8 525
半阙折子戏
半阙折子戏 2020-11-29 06:23

Pre Marshmallow my app would obtain it\'s device MAC address via BluetoothAdapter.getDefaultAdapter().getAddress().

Now with Marshmallow Android is retu

8条回答
  •  青春惊慌失措
    2020-11-29 07:12

    First the following permissions have to be added to Manifest;

    
    
    
    

    Then,

    public static final String SECURE_SETTINGS_BLUETOOTH_ADDRESS = "bluetooth_address";
    
    String macAddress = Settings.Secure.getString(getContentResolver(), SECURE_SETTINGS_BLUETOOTH_ADDRESS);
    

    After that the application has to be signed with OEM / System key. Tested and verified on Android 8.1.0.

提交回复
热议问题