在Android Studio Java.lang.securityexception中查找错误:需要Android.permission.bluetooth_connect

发布于 2025-01-25 01:57:44 字数 951 浏览 2 评论 0原文

我是Android Studio的新手。我试图使用Android版本12的新Android APK(SDK 31)连接到兄弟标签QL-820NMB,该设备也是Android 12本身。我尝试配对配对的设备。但是,当我尝试访问代码中的配对设备时,查找行中的错误

set< bluetoothdevice>配对Devices = bluetoothadapter.getBondedDevices();

and exception is ...

system.err:java.lang.securityexception:need need android.bluetrise.bluetrise.bluetooth_connect for Attribites for AttribitessOrtionSource { 。

<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

并根据建议的文件更新了推荐的移动更新,并将brotherprintlibrary Jar更新为AAR。

但是,仍然无法访问蓝牙并获得与上述有任何解决方案相同的安全性例外,或者我知道我缺少移动设备或代码中的任何配置问题。

我忘了提到相同的APK在Android 7设备中工作正常,但在Android 12中不行。

I am new to Android studio. I am trying to connect to brother label printer QL-820NMB with the new Android APK (SDK 31) with android version 12 and the device is also android 12 itself. I tried pairing the device it gets paired. But when I tried to access the paired devices in the code finding the error in the line

Set<BluetoothDevice> pairedDevices = BluetoothAdapter.getBondedDevices();

And Exception is...

System.err: java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource { uid = 0000, packageName = com.xyz.xyz, attributionTag = null, token = android.os.xyz, next = null }: AdapterService getBondedDevices

I have provided all the manifest for permissions .

<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

and also updated the mobile updates recommended and also updated the BrotherPrintLibrary jar to aar as recommended file.

But still unable to access the Bluetooth and getting the same Security Exception as above is there any solution or can I know am I missing any configuration issue in the mobile or the code.

I forgot to mention the same APK is working fine in Android 7 device but not in Android 12.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文