Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set permissions for Android Bluetooth

I'm new to Android development. I'm trying to get a simple HelloWorld app going on my (rooted) phone - and the app is trying to enable Bluetooth.

I've set the Bluetooth permissions in my manifest is as follows, but I'm getting a Permission Denial exception when I try to run the application on my phone via Eclipse:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.helloandroid"
          android:versionCode="1"
          android:versionName="1.0">      
        <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true" android:permission="android.permission.BLUETOOTH_ADMIN">
            <activity android:name=".HelloAndroid"
                      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>


<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-sdk android:targetSdkVersion="7" android:minSdkVersion="5"></uses-sdk>
</manifest>

Is there something obvious I'm missing?

like image 479
Jon Mills Avatar asked Aug 03 '10 19:08

Jon Mills


2 Answers

I'm not quite sure what the problem was here.

All I can say is that I reinstalled Eclipse and its plugins and now everything is working fine. Thanks for your help Mayra - I'll up-mark your answer because of your helpful and friendly approach.

like image 91
Jon Mills Avatar answered Oct 03 '22 04:10

Jon Mills


The answer about what to include in your manifest.xml for bluetooth activity includes

<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

The first three are of greater priority and as I'm sure you're aware there are different cases when each dependency may be required. Hope it helps with your setup!

like image 26
Julian Wise Avatar answered Oct 03 '22 03:10

Julian Wise