我正在开发一个Android应用程序(键盘驱动程序),首先我将蓝牙键盘与Android设备连接,在我的Inputmethod服务成功连接后,我正在接收按键并将其发送到当前打开的编辑器。问题是我无法弄清楚如何在android中打开/关闭大写锁定和移位键功能。
任何帮助!!
这是从蓝牙键盘接收密钥的广播接收器
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));
}
}
};
答案 0 :(得分:0)