This may be considered to be a repeat of this post, but that never did receive a proper answer, so maybe the question needs a bit more context to attract an answer.
Basically I have managed to set up a monitoring Service
that watches for home screen rotation, and when that happens my AppWidgets
are refreshed in response.
Whilst this works fine as far as it goes, a big pitfall with the method is that it actually only detects screen rotation and not specifically home screen rotation.
So, typically a device would support rotation of the screen within normal apps (i.e. rotation of an Activity
). The problem is that rotation of the screen in those circumstances falsely triggers my monitoring Service
.
My widgets then think that they need to fetch and show new content for the rotated view, but if the home screen itself does not support home screen rotation, then that work is not only wasted but also contributes to a bad UI.
So is there a way to check whether the launcher supports home screen rotation? Or alternatively, a way in which rotation of the home screen specifically can be detected, and not just rotation of the screen (e.g. in an app)?
I could just create an option to enable this rotation feature or not, with the default being off, but really I'd like the default to be that the feature is enabled... otherwise users with rotating home screens will consider that my widgets don't respond well to rotation, without taking the time to look into the options to enable the feature for their device.
Despite enabling screen auto-rotate on your phone, some apps might refuse to rotate automatically until you tell them to do so. These apps include video players, launchers, etc. They turn off screen auto-rotation by default to minimize distractions and unwanted screen rotations.
Meaning, you can rotate an Android smartphone from portrait to landscape when viewing any of your home screens and the interface will adjust to accommodate the device's orientation.
This answer should be bored you. But in fact, you cannot know exactly one launcher is supported rotation or not or detecting when launcher is rotated.
Launcher is just an normal android application. And for satisfying your requirement, they should:
Content Provider
: for you to know they supports rotate or not. What can they do etc ... and have a well-known document.BroastCastReceiver
for you to listen to that event.Often, they don't.
Home (or launch) screens are very specific, and there aren't definitive means by which one can express the orientation of every single one. Hell, you could have a home screen that is diagonal!
Because there is a huge amount of launch screen implementations, the behavior on any given device would be indeterminate.
However: You could easily add a check-box of some sort on the first run that asks the user if their home screen supports shifts in orientation. This would be terribly easy to add in, and wouldn't impose too much of a hassle on the user! :)
Edit: If you want to determine which activity is having its orientation changed, you can simply get a list of all running applications with getRunningAppProcesses
and then check each resulting item's importance
for IMPORTANCE_FOREGROUND
. This way, you'll know whether or not the user has changed the orientation whilst a running application had the foreground, and can check whether or not it was an app or the home screen that had called onConfigurationChanged
!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With