Viv*_*vek 6 android bluetooth android-bluetooth
我最近正在创建一个使用蓝牙的应用程序。问题是当我启动蓝牙服务时我的应用程序崩溃了。这是我的清单文件
<?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>
Run Code Online (Sandbox Code Playgroud)
现在,如您所见,我已经添加了蓝牙和蓝牙管理员的权限。
我的应用程序如何崩溃并且在 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."
Run Code Online (Sandbox Code Playgroud)
但我已经添加了权限,如您所见。现在为什么会发生这种情况?
尝试再添加一项权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Run Code Online (Sandbox Code Playgroud)
参考文献。: Android 权限蓝牙清单错误
注意:还要检查设备是否支持蓝牙功能:
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5681 次 |
| 最近记录: |