2013-08-29 53 views
0

在我的藍牙應用程序中,我得到了下面的例外,任何人都可以幫助解決這個問題。Android藍牙許可例外

08-29 13:07:08.370:E/DatabaseUtils(31342): java.lang.SecurityException異常:權限 拒絕:寫com.android.bluetooth.opp.BluetoothOppProvider URI 內容:// COM從PID = 9760,UID .android.bluetooth.opp/btopp = 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> 

回答

1

如果您嘗試使用Android 4.1或更高版本,則直接寫入內容提供者的權限現在受「signed」保護,這意味着您必須使用與用於簽名的相同密鑰藍牙應用程序。

來源this回答幾乎類似的問題Android bluetooth print stopped working on 4.1。查看解決方案的鏈接。

+0

我沒有使用那種意圖類型我正在使用bluetoothShare類發送文件..你提到的答案已完成工作已完成。 – Arut

+0

我也使用android 2.3以及4.3 – Arut