Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bluetooth_admin permission error

Regarding Android bluetooth discovery.

Getting this error from manifest permission error. However, the only errors that I found posted, was that they forgot to put the permission outside the application. This is however not the case here.

The program is tested on a Galaxy S2 running Jelly Bean 4.1.

The error is as follows:

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.

Basically the manifest looks like:

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

And the class where the error occurs:

 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");
}

Hope for an answer, what is going wrong :).

Thanks!

like image 378
Hans Peterson Avatar asked Sep 29 '26 04:09

Hans Peterson


1 Answers

Change

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

to

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

<user-permission> is used to regulate the access to the current component by other application. You should try <uses-permission> to get the privilege.

like image 76
StarPinkER Avatar answered Sep 30 '26 17:09

StarPinkER



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!