我使用該函數用於模擬鍵碼:模擬鍵代碼,所有的應用程序
public static void simulateKey(final int KeyCode) {
new Thread() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyCode);
} catch (Exception e) {
Log.e("Exception when sendKeyDownUpSync", e.toString());
}
}
}.start();
}
但我想用它所有的應用程序。例如,如果應用程序A在背景上模擬一些鍵碼,它應該在應用程序B在上面時工作。
它不可能我害怕。每個應用都在自己的沙箱中工作。 – Stan
但我可以顯示吐司消息或從其他應用程序啓動意圖有什麼區別? – Shockelduck
區別在於誰在控制。 –