1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Read bluetooht keyboard mode device in a service

Discussion in 'Android Questions' started by Dey, May 10, 2019.

  1. Dey

    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

    Code:
    <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: May 10, 2019
  2. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice