I have a simple application that still just turns on / off bluetooth when I run it on an emulator or on nexus 7, it says that my application has stopped responding and then closes when it starts. I tried to add the onStart () method, as I fixed this problem in a similar question, adding an intention that gets user permission and switches various things to different methods, but still crashes.
Logcat has the following messages:
07-29 01:05:41.541: E/AndroidRuntime(9745): FATAL EXCEPTION: main 07-29 01:05:41.541: E/AndroidRuntime(9745): java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackagename/mmypackagename.MainActivity}: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10067 nor current process has android.permission.BLUETOOTH.
Here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mypackagename" android:versionCode="1" android:versionName="1.0" > <uses-feature android:name="android.hardware.bluetooth" android:required="true" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BlUETOOTH"/> <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16" /> <application android:icon="@drawable/homeiconsmall" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/title_activity_main" android:launchMode="singleTask" android:alwaysRetainTaskState="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
source share