gpt4 book ai didi

安卓权限错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:33:57 25 4
gpt4 key购买 nike

我创建了一个启用蓝牙并发现其他设备的应用程序。在 list 中我有以下内容:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

但是,在设备上有这个异常:

11-20 08:08:47.766: E/AndroidRuntime(9380): FATAL EXCEPTION: main
11-20 08:08:47.766: E/AndroidRuntime(9380): java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10111 nor current process has android.permission.BLUETOOTH.

我还必须向 Manifest 添加什么才能使其正常工作?

这是 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cajun.meet"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".CajunMeetActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".MyULCard"
android:label="@string/app_name">
</activity>

<activity android:name=".MyULContacts"
android:label="@string/app_name">
</activity>

<service android:name = ".BluetoothExchange" android:exported="true" android:enabled="true">
</service>

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

</application>
</manifest>

最佳答案

尝试将权限移到 <application> 之外标签。如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cajun.meet"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".CajunMeetActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".MyULCard"
android:label="@string/app_name">
</activity>

<activity android:name=".MyULContacts"
android:label="@string/app_name">
</activity>

<service android:name = ".BluetoothExchange" android:exported="true" android:enabled="true">
</service>

</application>
</manifest>

关于安卓权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8202095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com