I want to develop an Android application in order to capture events (key press, touch, ...). The problem is that when my application is minimized, it cannot capture events. One solution can be using message sent from OS kernel to processe开发者_C百科s but I do not know how. I will be appreciated if anybody can help me.
The problem is that when my application is minimized, it cannot capture events.
Correct.
I will be appreciated if anybody can help me.
Fortunately, what you want is impossible, as it would represent a massive security hole.
You'll probably want to create an Intent Filter. Intents are Android's way of notifying applications when something interesting happens that they may want to be aware of. If you scroll down on the intent page you can see the list of actions/events that are exposed through intents. From there you create an IntentFilter as part of your app definition in your Android Manifest file.
Here is an example of the manifest for responding to a Search button click:
<intent-filter>
<action android:name="android.intent.action.SEARCH_LONG_PRESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
You can find some good information on how intents work and how to set them up on the Intents and Intent Filters page of the developer docs
精彩评论