简体   繁体   English

java.lang.SecurityException:UID 10457 / PID 24525 缺少权限 android.permission.BLUETOOTH

[英]java.lang.SecurityException: UID 10457 / PID 24525 lacks permission android.permission.BLUETOOTH

Android app giving: Android应用程序给予:

java.lang.SecurityException: UID 10457 / PID 24525 lacks permission android.permission.BLUETOOTH

When I try to connect with Bluetooth printer using BluetoothDevice().connect() in Xiaomi android 12当我尝试在小米 android 12 中使用 BluetoothDevice().connect() 连接蓝牙打印机时

I am trying to connect with Bluetooth thermal but am not able to do it in android 12我正在尝试连接蓝牙热,但无法在 android 12 中进行

First you have to add user-permission.首先,您必须添加用户权限。

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

And then your codes, you have to check if the user is using Android 12. If yes, check the permission Bluetooth.然后您的代码,您必须检查用户是否使用 Android 12。如果是,请检查蓝牙权限。 And then you can able to use the Bluetooth.然后你就可以使用蓝牙了。

Example here I use library from here.此处的示例我使用此处的库。 https://github.com/Karumi/Dexter https://github.com/Karumi/Dexter

private void checkPermissionBluetooth() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
        final ArrayList<String> listPermission = new ArrayList<>();
        listPermission.add(Manifest.permission.BLUETOOTH_CONNECT);
        listPermission.add(Manifest.permission.BLUETOOTH_SCAN);

        Dexter.withContext(Kpp02NewActivity.this).withPermissions(listPermission).withListener(new MultiplePermissionsListener() {
            @Override
            public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
                threadBluetoothEnable();
            }

            @Override
            public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {

            }
        }).check();
    } else {
        threadBluetoothEnable();
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.SecurityException:需要 BLUETOOTH 权限:用户 10065 和当前进程都没有 android.permission.BLUETOOTH - java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10065 nor current process has android.permission.BLUETOOTH Java.lang.SecurityException:Android中的安全权限? - Java.lang.SecurityException:SECURE PERMISSION in android? java.lang.SecurityException:发送短信:uid 10282 没有 android.permission.SEND_SMS - java.lang.SecurityException: Sending SMS message: uid 10282 does not have android.permission.SEND_SMS java.lang.SecurityException: UID 10243 在 Android 10 中没有粗略/精细定位权限 - java.lang.SecurityException: UID 10243 does not have Coarse/Fine Location permission in Android 10 java.lang.SecurityException:需要 android.permission.BLUETOOTH_CONNECT 权限以获得 AttributionSource - java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource 如何修复java.lang.SecurityException:调用者缺少必需的权限com.google.android.things.permission.USE_PERIPHERAL_IO错误? - How to fix java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO error? java.lang.SecurityException:发送短信:uid 10051 没有 android.permission.SEND_SMS - java.lang.SecurityException: Sending SMS message: uid 10051 does not have android.permission.SEND_SMS 在 android studio java.lang.SecurityException 中查找错误:需要 android.permission.BLUETOOTH_CONNECT - Finding Error in android studio java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT 权限违规 - uid=10293 不允许 getConfiguredNetworks,原因=java.lang.SecurityException:UID 10293 没有位置权限 - Permission violation - getConfiguredNetworks not allowed for uid=10293, reason=java.lang.SecurityException: UID 10293 has no location permission java.lang.SecurityException:权限被拒绝 - java.lang.SecurityException: Permission denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM