android - 在 Android 10 中获取蓝牙本地 mac 地址
问题描述
由于安全原因,bluetoothAdapter.getAddress() 从 Android Marshmallow 返回 02:00:00:00:00:00。我尝试从 android.provider.Settings.Secure 获取但仍然失败。那么有没有办法获取本地蓝牙mac地址呢?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bluetooth_address = android.provider.Settings.Secure.getString(getContentResolver(), "bluetooth_address");
address = findViewById(R.id.address1);
address.setText(bluetooth_address);
}
“我希望 textView 会设置为 6B:3E:CB:2E:C4:C7,但实际输出为空。”</p>
解决方案
推荐阅读
- discord - 我如何让 Discord 机器人(用 Python 制作)访问网站并从网站获取号码?
- javascript - 如何在位于同一 PHP 页面的两个 iframe 之间传递数据
- c# - 如何在 FHIR API 中获取元素?
- web-services - 反应式 Web 服务和背压
- sql-server - SQL Server 正则表达式交替
- html - 如何避免可调整大小的文本容器中不必要的间距?
- c# - 如何将一个月的所有日子添加到C#中的组合框
- scala - What does an asterisk mean in function signature in scala?
- c# - SendKeys.Send() 没有像我预期的那样发送或反应
- reactjs - 如何用来自状态的数据填充输入字段?