Android simulate key press ; I want to apply this answer to my app which when call activity was started number pressed itself but I have problem with these , how can I fix it I cannot find ,If there exist please share link .
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("tel:090"));
startActivity(i);
new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
for ( int i = 0; i < 10; ++i ) {
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_1);
Thread.sleep(2000);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_2);
Thread.sleep(2000);
}
}
catch(InterruptedException e){
}
}
}).start();