Intent for screen orientation change

倾然丶 夕夏残阳落幕 提交于 2019-12-11 10:04:51

问题


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)



来源:https://stackoverflow.com/questions/4349353/intent-for-screen-orientation-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!