在我的应用程序中,我正在使用进度条执行一些过程,当时我可以将屏幕模式从纵向更改为横向,然后我的应用程序被强制关闭。
如何处理这个问题?
最佳答案
它不会“强制您的应用程序关闭”,它只是重新启动 Activity 。这是default behaviour :
To make Android app development easier, the Android system automatically handles configuration change events and restarts the current activity with the new configuration. This is the default behavior that lets you declare resources like layouts and drawables based on the orientation, screen size, locale, etc.
While this behavior is really powerful, since your application adapts automatically to the device's configuration at runtime, it is sometimes confusing for new Android developers, who wonder why their activity is destroyed and recreated.
但是,您可以编写 Activity 以声明它可以自行处理屏幕方向更改。查看Dev Guide了解如何做到这一点。
关于android - 如何处理屏幕方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5867931/