Android Bluetooth pairing dialog shows less than 1 second - android

This post is here to help people from my brief experience with a bug of the Bluetooth pairing dialog on my phone.
Context:
I was unable to pair my smartwatch with my Google Pixel 5 running Android 12. When I try the pairing from the Bluetooth menu, the PIN shows on my Withings ScanWatch and the popup to enter the PIN shows on my smartphone. But after less than 1 second it closes automatically. So I wasn't able to enter the PIN :(
What I tried:
restart my phone and my watch
delete all my Bluetooth devices already paired
delete the cache of the "Bluetooth" application
do the pairing in safe mode
I don't want to reset my phone, so I would like to find another solution.

Solution:
Go in the "Developer options" (search on Google if not already enabled)
Check "Enable Gabeldorsche"
It is the new Android BLE stack written in Rust.
With this option checked, the dialog asking for the pairing PIN remains visible and gives me enough time to enter the PIN.
Hope it can help somebody ;)

Related

Bluetooth pairing pop up in android is appearing in two dialog screen one is (just pair) and another one is user enter pin

While initiating pairing firstly it will ask pair with device (device name)i.e just pair pop up appears on click of OK button one more pairing pop up appears requires user input (pin)is required to pair. I want a user input pairing pop up dont want just pair pop up we require only one pop up in android device. How do we archive in android devices? Please suggest.
I observed in IOS devices we are receiving only one pairing pop up dialog i.e ( user to enter pin) but in android devices we are receiving 2 pop up dialog. Please let me know the root cause.
I am using Xamarin forms to run on android & IOS . I tried to initiate the pairing by reading characteristic and receiving two pairing pop up. in IOS it is only one.

How to use the USB_DEVICE_ATTACHED intent-filter in Android for a USB device that is always connected

I have a scenario where I want an app to open when it detects that it's connected to a USB device. I have used an approach similar to this (it is using a USB_DEVICE_ATTACHED intent-filter and I have the ID's defined in an xml) and it is working for the most part. The problem I'm having is that when the Android Tablet powers on, the tablet will already be connected to the USB device, so the app doesn't get the USB_DEVICE_ATTACHED event. This then requires me to start the app manually after power up, which leads to me getting this unwanted dialog screen each time:
Allow App to access USB?
[ ] Always open App when USB is connected
Cancel OK
It makes no difference if I check the "Always open" box. It still shows up each time. I have tried using a broadcast receiver to open the app when the app powers on, and I still get the dialog window.
So I'm wondering:
Is there is a way to see get a USB_DEVICE_ATTACHED event when I first power on?
Or is there a way to not display the unwanted dialog screen each time I open the app manually?
I would really appreciate any suggestions. Thanks!

Programmatically Connect + pairing doesn't always work for some of the android devices

I am trying to achieve the following :
Select a device from the scan results of BluetoothLeScan.
Trying to connect to this device using BluetoothGatt.connect()
Once the connection has been established, I try to createBond with the connected device as well.
When this bond process is initiated I exchange the pin programmatically.
Once this pin is exchanged with the peripheral device, I setPairingConfirmation(true) to dismiss the enter pin dialog.
Problem - This doesn't work always. The pin isn't always exchanged successfully. Although the pin is written to the bluetooth stack successfully, but the pin received by the peripheral device is not the same. For some manufacturers like Samsung this problem has lower reproducibility but for others like iBall, this is 100% reproducible.
Please suggest

screencasting in android using HDMI wifi dongle

I have been searching a lot for implementing screen cast(miracast) in android and got more confused. I have a HDMI wifi dongle. Now as i plug the dongle and open my app need to search for available devices and as user selects devices the mirroring should start and my screen need to reflect to the device which has plug the device. For now From settings we need to go to display and turn wireless display on and connect to them. As of now i tryed to do this by WifiP2pManager class and got a list of device and connected to my device. But it is not showing as connected on settings wireless display which need to be connected for screen casting. Now my question is can i start that casting from my app and how ?
there is no public API that allows you to manipulate directly the connection, but you can integrate an action that should do what you want, through the MediaRouteActionProvider
Using this, you can display a button inside your action bar. When the user will click on it, it will show the list of paired devices and do a quick scan. From there, the user will be able to directly initiate the connection to an available device.
It's working on most devices, simply not returning the action on those that don't have any paired devices or don't support Miracast (+some Samsung's that don't use the MediaRoute system for Miracast connection).
I need to have have a button that simply starts miracast(mirroring)
That's not possible through the Android SDK, sorry. Whether there is a way for an app running with superuser privileges on a rooted device to do it, I cannot say.

Bluetooth paring

Is there a possibility to force dialog show to user for entering a PIN.
I have a barcode reader, that on server side (I think), and he need to get a PIN code. But the problem is that all androids up 2.2 don't won't to show dialog. (The 2.2. show dialog and the pairing are ok).
In my code I reach discovering devices, and the next step is a paring.
I will be thankful for give me some explanations
A Simple answer would be NO, It can't be possible to force user in PIN dialog as it is system generated.
You may create your own System checking for bluetooth pairing. A BroadCastReceiver will help you in this matter.

Categories

Resources