Android权限:应用程序崩溃需要蓝牙权限 [英] Android Permission: App crashes needing bluetooth permission

查看:113
本文介绍了Android权限:应用程序崩溃需要蓝牙权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was recently creating an app that uses bluetooth. The problem is my app crashes when ever I start the bluetooth service. Here's my manifest file

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

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

Now as you can see I have added permission for bluetooth and bluetooth admin.

我的应用程序为何崩溃并且在LOGCAT中错误是

How ever my app crashes and in LOGCAT the error is

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

但是您已经看到,我已经添加了权限.现在为什么会这样?

But I have added permission as you can see. Now why is this happening ?

推荐答案

尝试再添加一个权限:

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

参考.: Android许可BLUETOOTH清单错误

注意:也请检查设备是否支持蓝牙功能:

Note : also check device support Bluetooth feature or not using :

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

这篇关于Android权限:应用程序崩溃需要蓝牙权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆