1 回答
慕运维8079593
TA贡献1876条经验 获得超5个赞
我已经通过使用广播接收器类解决了这个问题。
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("GET_KEY_KEY")) {
String msg = intent.getStringExtra("msg");
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT));
}
}
}
}
然后我向我的服务发送了一个广播。
Intent intent = new Intent();
intent.setAction("GET_KEY_KEY");
sendBroadcast(intent);
添加回答
举报
0/150
提交
取消