I need help with the code How to Communicate with a Custom BLE using an Android App

Thread Starter


Joined May 10, 2016
Hi, my name is Nick and I have implemented this BluetoothLeGatt code in my
Android Studio. It shows no errors. So I click run. It finishes with
message: “Gradle Build successful”. I then can see the ADB and can
choose. First time I had the Nexus 5X with API 22 on it. It ran the
application but failed to load the UI on the virtuell device. Toast message:
BLE not supported. Seconde Toast message: Bluetooth not supported. That is
the Nexus 5X API 22 in Android Studio on Win10 Home edition. So the virtuell
device loads but I can’t really do anything with it. I then chose to load
the app on my real Android Phone the OneplusOne which started out with
KitKat 4.4.4 but got upgraded twice and is now running Marshmallow 6.0.1.
Its loading the app on the phone but it doesn’t show the UI with buttons
on it. Like your phone is showing: Write Char, Read Char, no data. That is
not showing on the virtuell device nor on my real phone. It does show the
top menu Bar with the BLE logo on the left. To the right it shows the scan
button. I can click it but it won’t find my Bluetooth device. The BLE
device is from Adafruit, the Feather 32u4 with the Nordic chip nRF51822 on
it (https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/overview).
Again, on my real phone it won’t show the UI with the 2 buttons on it
either. The build on the real phone is successful but with those Notes:
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details. And on the very buttom on
the right pane it shows this message:
Total time: 22.369 secs
On the left pane in Android Studio it shows these messages:
E/BluetoothAdapter: Bluetooth binder is null and those messages:
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb429fc40,
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb429fc40,
So the conclusion:
None of the chosen Virtuell devices loads the app in Android Studio.
The app is loding on my real phone but no UI buttons are showing.
I get those messages on the left window pane in Android Studio when running
on my real phone:
W/Binder: Caught a RuntimeException from the binder stub implementation.
java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or
ACCESS_FINE_LOCATION permission to get scan results
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.os.Binder.execTransact(Binder.java:453)
I/Choreographer: Skipped 125 frames! The application may be doing too much
work on its main thread.
W/IInputConnectionWrapper: getExtractedText on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
I do have the bluetooth adapter on win10 turned on and It can see the BLE
device and the blue LED on the bluetooth device is turned on to indicate a
conneciton. That is never the case with your app.
Also, when I try to make a signed apk it renders the error that it can’t
read the keystore or it was tampered with or the password is wrong. However,
it makes an Aplication-debug.apk. But when I take it and load it on my phone
it does the same thing as running it from Android Studio. It won’t show
the UI buttons on it. It lets me scan but won’t find the device.
So, could you be so kind to help me to make this project work in Android
Studio please?
I’m thinking that if it works on a virtuell device it will work on my
phone as well. That be really nice.