安卓权限 : App crashes needing bluetooth permission

标签 android bluetooth android-bluetooth

我最近正在开发一个使用蓝牙的应用程序。问题是当我启动蓝牙服务时我的应用程序崩溃了。这是我的 list 文件

<?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."

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

最佳答案

尝试再添加一个权限:

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

引用。 : Android Permission BLUETOOTH Manifest error

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

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

关于安卓权限 : App crashes needing bluetooth permission,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30679058/

相关文章:

android - 在 android 中使用 MQTT 的基本步骤

ios - 如何检测我的苹果设备是否支持低功耗蓝牙

java - 0x0A 和 0x0D 的区别

android - 使用 ScanSettings.SCAN_MODE_OPPORTUNISTIC '应用程序扫描太频繁'

android - 通过蓝牙将 Android Wear watch 和 Raspberry Pi 配对

android - 如何保持蓝牙连接后台?

android - 将项目从 listView 存储到应用程序的 SqLite 数据库

android - 如何确定是否已为 Cordova Apps 重新打开应用程序?

android - 保存状态异常

java - 跟踪鼠标光标android