Android back key by software -


dows know how can simulate pressing key software? i've seen applications simulate key , few other keys home , search. because theese weren't open source, tried build own application can manage theese tasks. go home example easy because had send 1 intent. so... can simulate key? :)

update:

i've downloaded open source application has same functions http://git.hoopajoo.net/

there it's done that:

process process = runtime.getruntime().exec("su"); outputstream outputstream = process.getoutputstream(); string cmd = "keycode " + keyevent.keycode_back; outputstream.write((cmd + "\n").getbytes("ascii")); 

where "keycode" command come from? not found called binary in android rootfs?!?!

aleadam method don't work on android 4.1.2. don't know why, workaround works:

public void dispachbackkey() {     dispatchkeyevent(new keyevent (keyevent.action_down, keyevent.keycode_back));     dispatchkeyevent(new keyevent (keyevent.action_up, keyevent.keycode_back)); } 

Comments