the below is one method to launch Android application by one
hardware key.
I use "keycodes" in init.
.rc in this method.
1.make sure "=y" in kernel
configuration file.
2.in init..rc, add below lines.
service launch_apk /system/bin/sh /system/bin/launch_apk.sh
disabled
oneshot
keycodes 270
270 is one example of key index.
3.add one script file named
launch_apk.sh in /system/bin/.
the context is as below.
am start com.example.sendintent/com.example.sendintentMainActivity
com.example.sendintent. is one example of Main
Activity of the targeted application.
4.in fact, this "keycodes" method is
designed to be used in debuggable mode, see below comments in
/system/core/init.keychords.c
// only handle keychords if ro.debuggable is set or adb is enabled.
// the logic here is that bugreports should be enabled in userdebug or eng builds
// and on user builds for users that are developers.
so if you want to use this method in the version faced to end-user, you
need do walk around here.
阅读(751) | 评论(0) | 转发(0) |