简体   繁体   English

需要 BLUETOOTH 权限:我在某些意图 Android Studio 中没有权限

[英]Need BLUETOOTH permission : i don't have permission in some intent Android Studio

I am trying to create an app with a MainActivity that opens other activities.我正在尝试创建一个带有打开其他活动的 MainActivity 的应用程序。 When I use bluetooth for activities other than the Main, it gives me this kind of error.当我将蓝牙用于 Main 以外的活动时,它给了我这种错误。 While in my MainActivity this is not a problem.在我的 MainActivity 中,这不是问题。

It tells me that I don't have the permissions:它告诉我我没有权限:

2022-01-07 18:50:38.881 9466-9466/com.example.myapplication_dynahers E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication_dynahers, PID: 9466
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication_dynahers/com.example.myapplication_dynahers.Calibration_Activity}: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10446 nor current process has android.permission.BLUETOOTH.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:8178)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
     Caused by: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10446 nor current process has android.permission.BLUETOOTH.

while my Manifest.xml specifies the permissions:而我的 Manifest.xml 指定权限:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication_dynahers">

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BlUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication_DynaHERS">
        <activity
            android:name=".Active_Bluetooth_Activity"
            android:exported="true" />
        <activity
            android:name=".Reset_Force_Activity"
            android:exported="true" />
        <activity
            android:name=".Calibration_Activity"
            android:exported="true" />
        <activity
            android:name=".Graph_Activity"
            android:exported="true" />
        <activity
            android:name=".Using_Version_Activity"
            android:exported="true" />
        <activity
            android:name=".Modify_Interval_Activity"
            android:exported="true"
            android:screenOrientation="portrait" />
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Where could the problem come from?问题可能来自哪里?

Here is my error: I actually put the correct permissions in the Manifest (I may be missing the permission for the location because it is possible to locate a device with bluetooth), but what I forgot to do is check the permissions in the code.这是我的错误:我实际上在清单中放置了正确的权限(我可能缺少该位置的权限,因为可以找到带有蓝牙的设备),但我忘记做的是检查代码中的权限。 This should solve my problem.这应该可以解决我的问题。

暂无
暂无

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

相关问题 权限拒绝:打开提供程序 com.android.providers.contacts.ContactsProvider2 Read_Contacts 并且我没有写权限 - Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 Read_Contacts and I don't have a write permission 在 android studio java.lang.SecurityException 中查找错误:需要 android.permission.BLUETOOTH_CONNECT - Finding Error in android studio java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT 为什么我没有将文件保存到SD卡的权限? - Why I don't have the permission to save the file into SD Card? Android通话意图权限 - Android Call Intent Permission 即使我已经声明 Android 权限也不起作用 - Android permission doesn't work even if I have declared it java.lang.SecurityException:需要 android.permission.BLUETOOTH_CONNECT 权限以获得 AttributionSource - java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource Android安全例外-没有权限ACCESS_NETWORK_STATE - Android Security Exception - Don't have permission ACCESS_NETWORK_STATE android studio - 蓝牙找不到手机的蓝牙 - android studio - Bluetooth don't find mobile's bluetooth JVM 异常发生:需要蓝牙权限:用户 10258 不是当前进程都没有 android.permission.Bluetooth python jnius? - JVM exception occured:Need Bluetooth permission: Neither user 10258 not current process has android.permission.Bluetooth python jnius? java.lang.SecurityException:需要 BLUETOOTH 权限:用户 10065 和当前进程都没有 android.permission.BLUETOOTH - java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10065 nor current process has android.permission.BLUETOOTH
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM