title: Running new Bluetooth Low Energy sample causes RuntimeException
body: <p>I've implemented the code in the <a href="http://developer.android.com/guide/topics/connectivity/bluetooth-le.html" rel="nofollow">Android 4.3 Bluetooth Low Energy</a> samples to find devices.</p>
  
  <pre><code>             final BluetoothManager bluetoothManager =
               (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
          BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
          mBluetoothAdapter.startLeScan(mLeScanCallback);
  </code></pre>
  
  <p>My manifest includes </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.BLUETOOTH"/&gt;
  &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/&gt;
  </code></pre>
  
  <p>and the device is a Nexus 4 which has been flashed with a factory 4.3 image.</p>
  
  <p>I had the thing working once, but on subsequent runs I get the following errors:</p>
  
  <pre><code>07-25 19:35:09.216 3308-3308/? E/AndroidRuntime: FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to start activity ComponentInfo{org.voltagex.adamtestapp/org.voltagex.adamtestapp.BluetoothTestActivity}: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10148 nor current process has android.permission.BLUETOOTH.
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
  at android.app.ActivityThread.access$600(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5103)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:525)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10148 nor current process has android.permission.BLUETOOTH.
  at android.os.Parcel.readException(Parcel.java:1431)
  at android.os.Parcel.readException(Parcel.java:1385)
  at android.bluetooth.IBluetoothGatt$Stub$Proxy.registerClient(IBluetoothGatt.java:708)
  at android.bluetooth.BluetoothAdapter.startLeScan(BluetoothAdapter.java:1487)
  at android.bluetooth.BluetoothAdapter.startLeScan(BluetoothAdapter.java:1448)
  at org.voltagex.adamtestapp.BluetoothTestActivity.onCreate(BluetoothTestActivity.java:103)
  at android.app.Activity.performCreate(Activity.java:5133)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
  ... 11 more
  07-25 20:13:17.567 1219-25094/? E/BtGatt.GattService: getService() - Service requested, but not available!
  07-25 20:13:29.210 1219-1219/? E/bt-btif: btif_enable_service: current services:0x100040
  07-25 20:13:29.210 1219-1219/? E/bt-btif: btif_enable_service: current services:0x140040
  07-25 20:13:29.220 1219-1219/? E/bt-btif: btif_enable_service: current services:0x140040
  07-25 20:13:29.880 1219-5621/? E/bt-btm: BTM_SecRegister:p_cb_info-&gt;p_le_callback == 0x730d7629
  07-25 20:13:29.880 1219-5621/? E/bt-btm: BTM_SecRegister: btm_cb.api.p_le_callback = 0x730d7629
  07-25 20:13:29.891 1219-5593/? E/bt-btif: Calling BTA_HhEnable
  07-25 20:13:29.891 1219-5593/? E/bt-btif: ## btif_config_get assert section &amp;&amp; *section &amp;&amp; key &amp;&amp; *key &amp;&amp; name &amp;&amp; *name &amp;&amp; bytes &amp;&amp; type failed at line:182 ##
  07-25 20:13:29.891 1219-5593/? E/bt-btif: ## btif_config_get assert section &amp;&amp; *section &amp;&amp; key &amp;&amp; *key &amp;&amp; name &amp;&amp; *name &amp;&amp; bytes &amp;&amp; type failed at line:182 ##
  07-25 20:13:29.891 1219-5593/? E/bt-btif: btif_storage_get_adapter_property service_mask:0x140040
  07-25 20:13:29.891 1219-5593/? E/bt-btif: ## btif_config_get assert section &amp;&amp; *section &amp;&amp; key &amp;&amp; *key &amp;&amp; name &amp;&amp; *name &amp;&amp; bytes &amp;&amp; type failed at line:182 ##
  07-25 20:13:29.901 1219-5624/? E/bt_mct: hci lib postload completed
  07-25 20:13:29.941 1219-5626/? E/BluetoothServiceJni: SOCK FLAG = 1 ***********************
  07-25 20:13:29.981 1219-5631/? E/BluetoothServiceJni: SOCK FLAG = 0 ***********************
  07-25 20:14:27.142 5765-5765/? E/AndroidRuntime: FATAL EXCEPTION: main
  java.lang.NullPointerException
  at org.voltagex.adamtestapp.BluetoothTestActivity$2$1.run(BluetoothTestActivity.java:120)
  at android.os.Handler.handleCallback(Handler.java:730)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5103)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:525)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>