有没有办法将密钥或字符发送到另一个程序活动?像C# SendKey method
这样的东西答案 0 :(得分:0)
您可以使用此方法:
private String key;
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Log.i("Key pressed was : ", String.valueOf(event.getKeyCode()));
key = String.valueof(event.getKeyCode());
return super.dispatchKeyEvent(event);
}
然后使用Intent
您可以将值发送到另一个活动
Intent intent = new Intent(this,MyActivity.class);
intent.putExtra("keyString, key);
并在您的其他活动中检索它:
Intent intent = getIntent();
String key = intent.getStringExtra("keyString");
编辑: On this site someone solved this problem (sending key events to an external activity)