简体   繁体   中英

Android: how to have my app open automatically?

Basically I want my app to start running in the background when the ACTION_MEDIA_BUTTON is clicked. I've seen other apps do this, so it must be possible. I just don't know how it is possible. Some kind of special manifest code?

Currently my app can receive intents from the ACTION_MEDIA_BUTTON when it has been opened (and even running in the background) via intentfilter that I register in Java code of the main activity (when the app is first opened). But how would I have this button just... open up the app?

For reference, the following app can already do this functionality: https://market.android.com/details?id=com.kober.headset

Much appreciated, thanks.

Use a BroadcastReceiver and register for the intent. See this Android Developers Blog post for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM