如何拦截pssed在服务硬键$ P $? [英] How to intercept a hard key pressed in a service?

查看:132
本文介绍了如何拦截pssed在服务硬键$ P $?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是有拦截硬键被以推出一项活动使用服务pssed $ P $?

Is there anyway to intercept that a hard key was pressed by using a service in order to launch an activity?

在换句话说:是否可以处理的KeyEvent在服务

In other words : Is it possible to handle the KeyEvents in the Service?

推荐答案

有监听硬件密钥从任何的关键事件,除了当前活动的应用程序没有一般的方法。

There is no general way to listen for the key events of the hardware keys from anything besides the currently active application.

只有CAMERA按键事件可以被检测到,通过其广播意图

Only the CAMERA button event can be detected, via its broadcast Intent.

的ACTION_CAMERA_BUTTON被广播时,摄像机按钮pressed并且不被前台活动截获: developer.android.com/reference/android/content/...

The ACTION_CAMERA_BUTTON is broadcast when the CAMERA button is pressed and is not intercepted by the foreground activity: developer.android.com/reference/android/content/…

这意味着你只能探测到preSS如果在前台应用程序不处理的关键preSS。

This means you can only detect the press if the application in the foreground is not handling the key press.

这篇关于如何拦截pssed在服务硬键$ P $?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆