You can get text from a bluetooth keyboard or scanner

2

I have a scanner that connects via Bluetooth but I need to capture what it scans when the screen is off.

Can it be done with a BroadcastReceiver? or some idea of how to start

    
asked by Heinz Keydel 20.08.2016 в 00:15
source

1 answer

3

The solution for this requirement was to place the screen in unlock mode none, implement the method onKeyIme() and it is very important to get the text in event.ACTION_UP since the event.ACTION_DOWN is the one that unlocks the screen therefore the character entry is lost.

    if (keyCode == event.KEYCODE_BACK && getAction() == event.ACTION_DOWN ){
     Log.i(EntregaStreetActivity.class.getName(),"back");
    }else if( event.getAction() == event.ACTION_UP){
     barcodebuffer += Character.toString((char) event.getUnicodeChar());
     Log.i(EntregaStreetActivity.class.getName(), "filterBarcodeKeys Char: "+ Character.toString((char) event.getUnicodeChar()));
    }
    
answered by 22.08.2016 в 18:41