I'm wondering whether android broadcasts a intent when the screen orientation changes. I am programming a live wallpaper and want to deal with it when the screen orientation changes. I can handle the same with regular apps.
问题:
回答1:
Android system doesn't broadcast an Intent, but restarts the activity by default.
If you want to override this you should override onConfigurationChanged(Configuration)
method of your activity. To get this method called you should also specify the changing in android:configChanges
attribute in your manifest file.
See what and how to specify here.
回答2:
I think "android.intent.action.CONFIGURATION_CHANGED" is what you want.
回答3:
I don't think it does, but you can always check the configuration at a repeating interval to see if it changed. To get the configuration call getResources().getConfiguration()
and inspect the orientation.
回答4:
Well if the app is not in the foreground, this
"onConfigurationChanged(Configuration)"
method does not work (for example when the app displays an overlay in a service)