0
votes

I am developing an android application (keyboard driver) in which first I am connecting Bluetooth keyboard with android device , after successful connection in my Inputmethod service I am receiving key presses and send it to currently open editor. The problem is that I am unable to figure out how to turn on/off caps lock and shift key functionality in android.

Any help !!

This is the broadcast receiver which is receiving keys from Bluetooth keyboard

private BroadcastReceiver key3Receiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        int key = Integer.parseInt(intent
                .getStringExtra(BluezService.COLONY_KEYPRESS_KEY));
        int action = intent.getIntExtra(BluezService.EVENT_KEYPRESS_ACTION,
                KeyEvent.ACTION_DOWN);
        Log.d("++++ key recieved   ", Integer.toString(key));

        InputConnection ic = getCurrentInputConnection();
        long eventTime = SystemClock.uptimeMillis();

        // ********* Hacks
        if(key==8)
        {
            key=127;
        }


        if (key < 130) {                
            ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, action,COLONYKEYCODE[key],
                    0, COLONYKEYCODE[key], 0, 0, KeyEvent.FLAG_SOFT_KEYBOARD));
        }

    }
};
1
Are you showing the Android soft Key board on the Screen while the user types something on the hardware keyboard? - Mukund Samant
no i am not showing soft keyboard. - Ahmed

1 Answers

0
votes

In your EditText (or wherever appropriate) use the attribute:

android:inputType="textCapCharacters"

to capitalize all letters by default. Read inputType for its other features.