Android Question Read bluetooht keyboard mode device in a service

Dey

Active Member
Licensed User
Hi everyone
I have this remote control https://www.amazon.it/kwmobile-Telecomando-Bluetooth-auto-moto/dp/B07F35DCLW
Bluetooth 4 compatible from Android version 4.3
works properly is seen as text entry.
I need to interface when the app is not first,
if possible by the starter service,
how can I do it, even using JavaObject or some library?
I tried with the BlueTooth library it finds it, but it doesn't connect in serial emulation.
I should understand how to read the keys eg volume + volume minus pause in a service.
I hope I was well versed.
Thank you


I found this
does anyone help me convert it?
https://stackoverflow.com/questions/19345705/key-listener-in-service

B4X:
<receiver android:name=".RemoteControlReceiver">
    <intent-filter>
        <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>
</receiver>



public class RemoteControlReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
            KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
            if (KeyEvent.KEYCODE_VOLUME_DOWN == event.getKeyCode()) {
                // Handle key press.
            }
        }
    }
}
 
Last edited:
Top