【问题标题】:Android Permission: App crashes needing bluetooth permissionAndroid权限:需要蓝牙权限的应用程序崩溃
【发布时间】:2015-06-06 04:56:28
【问题描述】:

我最近正在创建一个使用蓝牙的应用程序。问题是我的应用程序在我启动蓝牙服务时崩溃。这是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.petalappstudio.fit" >

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

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

现在你可以看到我已经添加了蓝牙和蓝牙管理员的权限。

我的应用程序如何崩溃并且在 LOGCAT 中出现错误

"java.lang.RuntimeException: Unable to start service " and is caused by
"java.lang.SecurityException: Need BLUETOOTH ADMIN permission: Neither user 10145 nor current process has android.permission.BLUETOOTH_ADMIN."

但是如您所见,我已经添加了权限。现在为什么会发生这种情况?

【问题讨论】:

    标签: android bluetooth android-bluetooth


    【解决方案1】:

    尝试再添加一个权限:

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

    参考。 :Android Permission BLUETOOTH Manifest error

    注意:还要检查设备是否支持蓝牙功能:

    <uses-feature android:name="android.hardware.bluetooth" android:required="true" />
    

    【讨论】:

    • 谢谢,没想到。 :)
    • 是的,我看到了,也添加了。很有帮助,谢谢:)
    • 好的,很高兴为您提供帮助,如果可以帮助您解决问题,请点赞。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 2013-09-01
    • 2021-11-26
    • 1970-01-01
    相关资源
    最近更新 更多