Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top