how to make a broadcast receiver catch ( menu, volume, home… ) button click?

天涯浪子 提交于 2019-12-13 04:38:13

问题


i want my broadcast receiver to be invoked when clicking on(menu, volume or any other possible button).

Is that possible?? Please help me

Regards


回答1:


Yes it is possible but don't waste your time to build an application, which is based upon menu button(hardware buttons like HTC phones) as some phones don't support menu buttons instead they offer you touch like LG phones.

You can add functionality to Power button, Volume Buttons Up and Down.

Here is the tutorial for you as a newbie.

http://www.vogella.com/articles/AndroidBroadcastReceiver/article.html

I will recommend you to study Broadcast Receiver in detail before start writing your code!

One last thing, do Study the differences between API 10 or lower and API 11 or higher, Because there arises a problem when you run you API 10 based Android App on API 11 or higher.

Also See, - Pending Intents - sendBroadcast()




回答2:


Is that possible?

Generally, no. A couple of buttons, such as the CAMERA button, will result in a broadcast, if the foreground activity does not consume the event. This is not true for the HOME button, or the MENU button (if one exists). I am not aware of broadcasts that are sent out for the volume buttons (if they exist), but I cannot rule out that there are some.



来源:https://stackoverflow.com/questions/19013856/how-to-make-a-broadcast-receiver-catch-menu-volume-home-button-clic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!