I'm trying to build a bluetooth connection between a phone and a sensor.
I have two Galaxy S3. My code works fine on one of them, but for the other, my code will always pause at the call mSocket.connect(), asking for the pairing code every time even if I have already paired the sensor with the phone in the Settings->Bluetooth
Please help!
Thanks!
Jake
I have figured this out. It's because one of my Galaxy phone is in Android 4.04 and the other is in 4.1. Update the Android version will do the trick.
Related
I've developed an Android app for remote controlling some special hardware devices. The communication is done via udp and wifi. The app already runs on ~60k devices without any problems but since the rollout of Android 6 I'm getting more and more reports from users who get some strange errors:
Usually the app searches for the hardware with a broadcast package. The app then requests all data from the hardware to stay in sync (~4000 packages in both directions). This sync process is heavily tested with all wifi conditions possible and does work as intended (also on Android 6).
User with a Samsung device and Android 6 are now having the issue, that the sync is unable to complete (no reply from the hardware within 20 seconds). The odd thing is that the broadcast search does work just fine, as well as the beginning of the sync. Usually the timeout happens when 5-15% of the sync was completed.
As I have no idea what could cause this issue I wanted to ask if there is any known problems with Samsung / Android 6 and udp communication via wifi?
Also were there any other changes on the network stack in Android 6 that could cause this issue? On my test devices (HTC mostly) everything runs fine so I'm currently out of ideas.
Edit:
I narrowed the issue down to the following devices:
Samsung Galaxy 6
Samsung Galaxy 6 Edge
Samsung Galaxy Note 5
Edit 2:
I got a Samsung Galaxy 6 device for testing purposes and of course it does work for me. I also tried all sorts of network setup, power saving, anti virus and general settings combination but it's just working all the time.
Edit 3:
After getting some Galaxy S5 and S6 test devices I was not able to reproduce the problem. Comparing the ROM version I found out that these devices all have a newer rom than the devices which got the issues.
Turns out that Samsung simply broke something in their wifi stack which causes the wifi to stop working properly after some udp packages. So only fix for this issue is to wait and hope they fix it in all countries soon.
The problem is the following: I'm working on an Android project at the moment that involves the connection of two Android devices. I've got the connection and data transfer working with the guidelines of http://developer.android.com/guide/topics/connectivity/bluetooth.html but my application only works with two specific devices, the Sony Xperia LT22i (Android 4.0.4) and the Samsung Galaxy S Plus (Android 2.3.6).
When I try it on other Smartphones, they can successfully connect and they receive the test-byte '1', with which I check if the connection is working. But when the actual data transmission starts, they don't receive anything and there is no Exception thrown.
I can add the code if needed, but it's the same as on the mentioned Android Developers page, with a few app-specific changes. Has anyone had this problem or knows how to fix it? Thanks in advance.
I am trying to connect a device with phone via bluetooth by calling following two function for the service. First one "mBluetoothGatt.getService(uuid)" and "BluetoothGattCharacteristic.getCharacteristic(UUID)".
Problem is sometimes one of the service returns null. Sometime back it was working correctly, but now its not working at all.
But it works when i restart the bluetooth of the phone. After sometime (5-6 mins) it again stops working.
Please help, on what steps to follows to debug further for getting it work.
Thanks in Advance.
Test using a second device. It is very possible that there might an issue with your current device.
You said you're checking multiple devices, are you also checking on multiple software versions. From what I have found a lot of android 4.4.X have this issue. From what I have found there is no push to the latest version that fixes the issue. This is a resolution that worked for some people.
Since the recent release of Android 5.0 Lollipop I am experiencing very bad performance of the Bluetooth Low Energy API in my Nexus 4 device. With the previous OS version (Android 4.4.4 Kit-Kat) it worked like a charm, and the very same app run on 5.0 has the following behavior:
Frequently it does not detect any advertising packet from the peripheral.
The ADVERTISING_INTERVAL of the peripheral is 20ms, so the app should detect at least one advertising in 60ms in the worst case. I have tried with BluetoothLeScanner (with SCAN_MODE_LOW_LATENCY settings) not to use the deprecated mBluetoothAdapter.startLeScan(mLeScanCallback) with no success.
When it does, when I try to connect to the GATT server it rarely does.
I have checked with a BLE sniffer that the CONNECTION_REQUEST packet
is not even sent to the peripheral.
It seems I'm not the only one with this kind of errors and some other users have posted similar questions. Does anybody know what has happened?
--
Update 1: (2014/12/17)
I have also tested the same app with a Nexus 5 running Lollipop and it rarely connects to the GATT server. Every time I send a connection request, it never does because the peripheral does not receive the packet. Before upgrading this Nexus 5 to Lollipop, it worked perfectly on Kit-Kat 4.4.4 though.
Update 2: (2014/12/17)
Android 5.0.1 does not solve the problem at all.
Update 3: (2015/04/23)
Android 5.1 does not solve the problem either. Today I've had the opportunity to test Android 5.0.1 on a SAMSUNG Galaxy S4 and it works perfectly. I have also tested on the Nexus 5 with a fresh Android 5.1 install, and it works fine too. The problem still remains in the Nexus 4. They made something strange on the the firmware of Android 5.0 and subsequent releases that broke the perfect compatibility Android 4.4.4 had with the Bluetooth API.
reedited to a clearer answer
Last week i had some problems with bt after upgrading to 5.0 . Maybe
you can stop the bt process from apps in settings and it possibly
will reset everything like so:
Settings -> Apps -> Scroll over to All -> Select Bluetooth Share -> Clear Cache.
Shutting those services in instantiate them have been known to solve
this issue in some cases. you can also follow this link if it is
more clear:
http://www.gottabemobile.com/2014/12/01/nexus-lollipop-problems-fixes/
In my case i am nor expert in Bluetooth but I did solve this problems
after many trials. And I discovered that unplaging the bt dongle from
pc help also.
It is not generally recommended to upgrade so soon without checking
competency to bluetooth. As far as I have understood bt is known to
have issues at each upgrade
Good luck with your endeavor. If this answer is not enough I hope you find help from someone else.
I Think I may have found the answer
I had the same problem, it took 2-5 minutes to connect to my device AFTER I upgraded to Lollipop
This took 5 seconds before the upgrade.
The Fix:
Old code :
mBluetoothGatt = mBluetoothDevice.connectGatt(this, true, mGattCallbackSync);
new code :
mBluetoothGatt = mBluetoothDevice.connectGatt(this, false, mGattCallbackSync);
I just changed the autoConnect argument to false. It takes 5 seconds to connect now.
I hope this works for you.
Can anyone tell me if there have been any changes to the bluetooth functionality in the Android update?
I have an app which uses transmission and reception concurrently with a total of 5 connected devices and this works perfectly on a Motorola Droid2 with 2.2.1 but not on the ATRIX running 2.3
There may of course be a hardware element involved but I wanted to establish this first.
thanks in advance.
John
I had the problem that the bluetooth connection worked only on the second try - the first one almost always fails internally (IOException). And you don't have much time in between trials. This was on my 2.3.3 Sony phone. Logcat showed some messages that might imply an internal problem in bluez or with the bluez/java integration.
This problem did not manifest on a 2.2.x Samsung phone. Note that my program only uses one connection at a time.
Android website says "updated BlueZ stack", but that's all.
Did you check the logs, what are the errors you're getting?
Also, I guess you can try running different emulators with different versions of Android and see how that behaves.