放在哪里code为全球硬件密钥监听器? [英] Where to put code for a global hardware key listener?

查看:158
本文介绍了放在哪里code为全球硬件密钥监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图破解硬件的关键支撑到现有的应用程序,但感悟到我知道的太少Android应用开发的继续。结果
我可以反编译,并重新编译应用程序,而无需使用APKtool问题,我做了一个小的应用程序自己用的​​硬件关键支撑拉动编译smali code出来。作为参考,这部分是这样的:

 。方法公开的onkeydown(ILandroid /查看/ KeyEvent的;)z

如果我想有应用程序监听硬件钥匙全球(即在每一次活动,窗口,什么具备的,你的应用程序的),在那里应该我把的onkeydown code吗?难道我把它在一个单一的活动(如果是这样,哪一个),在所有的活动,或别的地方干脆?

编辑:我实现了全球这里是一个有点暧昧。我的意思是在整个应用程序,而不是系统范围。


解决方案

  

如果我想有应用程序监听硬件钥匙全球(即在每一次活动,窗口,什么具备的,你的应用程序),我在哪里应该放的onkeydown code?


您下载的Andr​​oid源$ C ​​$ C,修改它有某种全球硬件密钥的处理程序,编译修改的源,将其打包为ROMmod,并在设备上安装的ROMmod。

否则,只有前景活性(或,有时,窗口)将接收的按键事件。

I'm trying to hack hardware key support into an existing app, but came to realize I know too little of Android app development to continue.
I can decompile and recompile the app without problems using APKtool, and I made a small app myself with hardware key support to pull the compiled smali code out of. For reference, that part looks like this:

.method public onKeyDown(ILandroid/view/KeyEvent;)Z

If I want to have the app listen for hardware keys "globally" (i.e. in every activity, window, what-have-you, of the app), where ought I put the onKeyDown code? Do I put it in a single activity (if so, which one), in all activities, or someplace else altogether?

Edit: I realize "globally" is a bit ambiguous here. I mean throughout the entire app, not system-wide.

解决方案

If I want to have the app listen for hardware keys "globally" (i.e. in every activity, window, what-have-you, of the app), where ought I put the onKeyDown code?

You download the Android source code, modify it to have some sort of global hardware key handler, compile the modified source, package it into a ROM mod, and install the ROM mod on your device.

Otherwise, only the foreground activity (or, sometimes, window) will receive key events.

这篇关于放在哪里code为全球硬件密钥监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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