2013-03-19 97 views
3

關於Android藍牙發現。Android Bluetooth_admin權限錯誤

從清單許可錯誤中獲取此錯誤。但是,我發現的唯一錯誤是,他們忘記將權限放在應用程序之外。然而,這不是這種情況。

該程序在運行Jelly Bean 4.1的Galaxy S2上進行測試。

的錯誤如下:

03-19 13:08:03.933: W/dalvikvm(12616): threadid=1: thread exiting with uncaught exception (group=0x413082a0) 
03-19 13:08:03.938: E/AndroidRuntime(12616): FATAL EXCEPTION: main 
03-19 13:08:03.938: E/AndroidRuntime(12616): java.lang.SecurityException: Need BLUETOOTH_ADMIN permission: Neither user 10004 nor current process has android.permission.BLUETOOTH_ADMIN. 

基本上清單的樣子:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.motioncontrol" 
    android:versionCode="1" 
    android:versionName="1.0" > 


    <user-permission android:name="android.permission.BLUETOOTH_ADMIN" />    
    <uses-permission android:name="android.permission.BLUETOOTH" /> 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:debuggable="true" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.motioncontrol.Main" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".AccelerometerDat" 
      android:label="@string/accelerator_title" /> 
     <activity 
      android:name=".GyroscopeData" /> 
     <activity 
      android:name=".Gravitydat" /> 
     <activity 
      android:name=".Linearacc" /> 
     <activity 
      android:name=".Bluetooth" /> 
     <activity 
      android:name=".CheckBluetooth" /> 
     <activity 
      android:name=".About" 
      android:label="@string/about_title" 
      android:theme="@android:style/Theme.Dialog" /> 
    </application> 


</manifest> 

而發生錯誤的類:

private void doDiscovery() { 
    if (D) Log.d(TAG, "doDiscovery()"); 

    // Indicate scanning in the title 
    setProgressBarIndeterminateVisibility(true); 
    setTitle(R.string.scanning); 
    Log.d(TAG, "indicates scanning"); 

    // Turn on sub-title for new devices 
    findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE); 
    Log.d(TAG, "Set up sub-title for new devices"); 

    // If we're already discovering, stop it 
    if (mBtAdapter.isDiscovering()) { 
     mBtAdapter.cancelDiscovery(); 
     Log.i(TAG, "Already running discovering, stop it!"); 
    } 

    // Request discover from BluetoothAdapter 
    mBtAdapter.startDiscovery(); 
    Log.d(TAG, "Request discover form BluetoothAdapter"); 
} 

希望的答案,出了什麼問題:)。

謝謝!

回答

8

變化

<user-permission android:name="android.permission.BLUETOOTH_ADMIN" />    

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

<user-permission>用於調節由其它應用程序的訪問的電流分量。您應該嘗試<uses-permission>以獲得特權。

+0

太棒了!這就是訣竅!非常感謝您的幫助:D – 2013-03-19 16:19:28

+3

它總是將小麻煩咬在屁股上。 – MattC 2013-04-26 14:24:01