1 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊
我已經(jīng)通過(guò)使用廣播接收器類(lèi)解決了這個(gè)問(wèn)題。
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));
}
}
}
}
然后我向我的服務(wù)發(fā)送了一個(gè)廣播。
Intent intent = new Intent();
intent.setAction("GET_KEY_KEY");
sendBroadcast(intent);
添加回答
舉報(bào)