我正在为我的小宝贝创建一个应用程序,因为她喜欢手机,但弄乱了我的桌面。我正在使用 NDK 做我的应用程序,我有以下内容....
static int32_t handle_input(struct android_app* app, AInputEvent* event) {
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
{
int key_val = AKeyEvent_getKeyCode(event);
switch(key_val){
case AKEYCODE_BACK:
LOGI("Back Button hit");
break;
case AKEYCODE_HOME:
LOGI("HOME HIT");
break;
}
LOGI("Input Recieved %d", key_val);
}
return 1;
}
但是当我点击后退按钮然后我看到主页按钮时......
I/native-activity(24450): Back Button hit
I/native-activity(24450): Input Recieved 4
I/native-activity(24450): Back Button hit
I/native-activity(24450): Input Recieved 4
I/ActivityManager( 278): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 278
是否有许可或我可以给它的东西让我抓住主页按钮的按下?似乎每个测试课都应该有......
TEST_F(KeyboardInputMapperTest, Process_SimpleKeyPress) {
const int32_t USAGE_A = 0x070004;
const int32_t USAGE_UNKNOWN = 0x07ffff;
mFakeEventHub->addKey(DEVICE_ID, KEY_HOME, 0, AKEYCODE_HOME, POLICY_FLAG_WAKE);