android - 如何处理屏幕方向问题

标签 android screen-orientation

在我的应用程序中,我正在使用进度条执行一些过程,当时我可以将屏幕模式从纵向更改为横向,然后我的应用程序被强制关闭。

如何处理这个问题?

最佳答案

它不会“强制您的应用程序关闭”,它只是重新启动 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/

相关文章:

ios - 我应该在我的 iOS 应用程序中启用还是禁用颠倒?

android - 打开无线网络 - 需要身份验证通知

java - 我正在将图片文件从电脑发送到 Android 手机,两者都通过套接字连接到同一 WLAN

android - 像 YouTube App 一样在 SLideMenu 中制作 ListView

android - 如何响应 Dialog 中的方向变化

android - 方向改变时视频不会调整大小

android - 无法在未调用 Looper.prepare 的线程内创建处理程序

Android服务不会自行重启

android - 如何全局检测屏幕旋转何时发生变化?

angular - Ionic 3 - 屏幕方向锁定不起作用