android - Running new Bluetooth Low Energy sample causes RuntimeException -


i've implemented code in android 4.3 bluetooth low energy samples find devices.

             final bluetoothmanager bluetoothmanager =              (bluetoothmanager) getsystemservice(bluetooth_service);         bluetoothadapter mbluetoothadapter = bluetoothmanager.getadapter();         mbluetoothadapter.startlescan(mlescancallback); 

my manifest includes

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

and device nexus 4 has been flashed factory 4.3 image.

i had thing working once, on subsequent runs following errors:

07-25 19:35:09.216 3308-3308/? e/androidruntime: fatal exception: main java.lang.runtimeexception: unable 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. @ android.app.activitythread.performlaunchactivity(activitythread.java:2211) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261) @ android.app.activitythread.access$600(activitythread.java:141) @ android.app.activitythread$h.handlemessage(activitythread.java:1256) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5103) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) @ dalvik.system.nativestart.main(native method) caused by: java.lang.securityexception: need bluetooth permission: neither user 10148 nor current process has android.permission.bluetooth. @ android.os.parcel.readexception(parcel.java:1431) @ android.os.parcel.readexception(parcel.java:1385) @ android.bluetooth.ibluetoothgatt$stub$proxy.registerclient(ibluetoothgatt.java:708) @ android.bluetooth.bluetoothadapter.startlescan(bluetoothadapter.java:1487) @ android.bluetooth.bluetoothadapter.startlescan(bluetoothadapter.java:1448) @ org.voltagex.adamtestapp.bluetoothtestactivity.oncreate(bluetoothtestactivity.java:103) @ android.app.activity.performcreate(activity.java:5133) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) @ android.app.activitythread.performlaunchactivity(activitythread.java:2175) ... 11 more 07-25 20:13:17.567 1219-25094/? e/btgatt.gattservice: getservice() - service requested, 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->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 && *section && key && *key && name && *name && bytes && type failed @ line:182 ## 07-25 20:13:29.891 1219-5593/? e/bt-btif: ## btif_config_get assert section && *section && key && *key && name && *name && bytes && type failed @ 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 && *section && key && *key && name && *name && bytes && type failed @ 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 @ org.voltagex.adamtestapp.bluetoothtestactivity$2$1.run(bluetoothtestactivity.java:120) @ android.os.handler.handlecallback(handler.java:730) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5103) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) @ dalvik.system.nativestart.main(native method) 

try add uses feature tag manifest. android know , expect feature available:

<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -