简体   繁体   中英

Background running app that shows a dialog when orientation changes

The title is pretty self explanatory. I want to create an android app that is always running and when the orientation is changed it shows a dialog. I was looking for some information I think I have to use Services but I'm not sure how, which one and why. I'm not even sure that's right.

So, to sum up: An android app that always (even though it's closed) detects the orientation changes and then show a dialog.

Any help would be nice. I'm really lost right now.

I think you will have to implement a service and within that service, register a BroadcastListener, listening to a broadcast with the action ACTION_CONFIGURATION_CHANGED . The onReceive() method of the Receiver will be called once anything within the current configuration, like the orientation, changes. Then you can open whatever you need to open from within that service and bring it to the foreground.

I'll leave the details for you, there's too much to be explained. Please read up on Service and BroadcastListener . I have not tested this myself either but conceptually I believe this is the way to do it.

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