【问题标题】:Android bluetooth permission exceptionAndroid蓝牙权限异常
【发布时间】:2013-09-01 12:48:49
【问题描述】:

在我的蓝牙应用程序中,我遇到了以下异常,任何人都可以帮助解决这个问题。

08-29 13:07:08.370: E/DatabaseUtils(31342): java.lang.SecurityException:权限 拒绝:写入 com.android.bluetooth.opp.BluetoothOppProvider uri content://com.android.bluetooth.opp/btopp 从 pid=9760, uid=10110 需要 android.permission.ACCESS_BLUETOOTH_SHARE,或 grantUriPermission()

我的清单文件是

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="process.bluetooth.sendfile"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="7"
    android:maxSdkVersion="17"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.BLUETOOTH" android:label="BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE"
    android:protectionLevel="signature" />

<application android:icon="@drawable/bluetooth" 
    android:label="@string/app_name"
    android:allowBackup="true">
    <activity android:name="process.bluetooth.sendfile.SendFileActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

【问题讨论】:

    标签: android android-manifest android-bluetooth


    【解决方案1】:

    如果您在 Android 4.1 或更高版本上尝试使用它,那么直接写入内容提供商的权限现在受到“签名”的保护,这意味着您必须使用用于签署蓝牙应用程序的相同密钥来签署您的应用程序。

    来源this 回答几乎类似的问题Android bluetooth print stopped working on 4.1。解决方案见链接。

    【讨论】:

    • 我没有使用那种意图类型,我正在使用 bluetoothShare 类发送文件。你提到的答案已经完美地完成了。
    • 我也在使用 android 2.3 和 4.3
    猜你喜欢
    • 1970-01-01
    • 2023-02-10
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    • 2022-11-11
    • 1970-01-01
    • 2022-09-27
    相关资源
    最近更新 更多