Android的权限错误 [英] Android permission error
本文介绍了Android的权限错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建的应用程序以支持蓝牙并发现其他设备。
在清单中我有以下几点:
<使用许可权的android:NAME =android.permission.BLUETOOTH/>
<使用许可权的android:NAME =android.permission.BLUETOOTH_ADMIN/>
然而,在设备上有此异常:
8月11日至20日:08:47.766:E / AndroidRuntime(9380):致命异常:主要
八月11日至20日:08:47.766:E / AndroidRuntime(9380):java.lang.SecurityException异常:需要蓝牙权限:无论用户10111也不是当前进程具有android.permission.BLUETOOTH。
还有什么我一定要添加到清单,以便它的工作原理?
这是清单:
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=cajun.meet
安卓版code =1
机器人:=的versionName1.0>
<采用-SDK安卓的minSdkVersion =8/><应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME> <活动机器人:名字=。CajunMeetActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT; <活动机器人:名字=。MyULCard
机器人:标签=@字符串/ APP_NAME>
< /活性GT; <活动机器人:MyULContactsNAME =
机器人:标签=@字符串/ APP_NAME>
< /活性GT; <服务机器人:名字=.BluetoothExchange机器人:出口=真正的机器人:启用=真正的>
< /服务> <使用许可权的android:NAME =android.permission.BLUETOOTH/>
<使用许可权的android:NAME =android.permission.BLUETOOTH_ADMIN/>< /用途>
< /清单>
解决方案
尝试移动&LT外的许可;用途>
标记。象下面这样:
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=cajun.meet
安卓版code =1
机器人:=的versionName1.0>
<采用-SDK安卓的minSdkVersion =8/> <使用许可权的android:NAME =android.permission.BLUETOOTH/>
<使用许可权的android:NAME =android.permission.BLUETOOTH_ADMIN/><应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME> <活动机器人:名字=。CajunMeetActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT; <活动机器人:名字=。MyULCard
机器人:标签=@字符串/ APP_NAME>
< /活性GT; <活动机器人:MyULContactsNAME =
机器人:标签=@字符串/ APP_NAME>
< /活性GT; <服务机器人:名字=.BluetoothExchange机器人:出口=真正的机器人:启用=真正的>
< /服务>< /用途>
< /清单>
I created an application which enables Bluetooth and discovers other devices. In manifest I have the following:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
However,on the device there is this exception:
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.
what else do i have to add to the Manifest so that it works?
This is the manifest:
<?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>
解决方案
Try moving the permission outside the <application>
tag. Like below:
<?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>
这篇关于Android的权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文