Transferred from: Http://www.dewen.io/q/11313/android+%E6%A8%A1%E6%8B%9F%E8%BF%94%E5%9B%9E%E9%94%AE%E5%8A%9F%E8%83%BD,
I found that there are two ways to do this.
①, Java.lang.Runtime
- Runtime Runtime = runtime. GetRuntime();
- Runtime. EXEC("Input keyevent" + keyevent. Keycode_back);
②, Android.app.Instrumentation
- Instrumentation Inst = new instrumentation();
- Inst. Sendkeydownupsync(keyevent. Keycode_back);
have been tested successfully. You can achieve the effect of pressing back.
Reviews3) • Link 2013-03-20
- 0 give force, praise a-mottled-neo 2013-03-20
- 0 very good, thank you for your answer, both methods are feasible, that is, instrumentation is a test environment simulation, do not know my production environment with this has wood problems, there is instrumentation this thing can not be used in the main thread, But open a thread on it, thank you very much –tlchencheng 2013-04-01
- 0 @tlchencheng Are you sure that you can do this by doing this, and that the return operation is possible in any program interface? –wangqi0609342013-08-04
-
About the Android return key code implementation