安卓:协助处理屏幕方向变化 [英] Android: Help handle screen orientation change

查看:177
本文介绍了安卓:协助处理屏幕方向变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做一个简单的计时器作为使用处理程序来调用一个可运行哪些更新UI的Andr​​oid应用程序的一部分。但是,当用户改变屏幕方向,应用程序重新启动。我看着的onSaveInstanceState(),但不会帮助我。

I'm making a simple timer as a part of an Android app using a handler to call a runnable which updates the UI. However, when the user changes the screen orientation, the app restarts. I looked into onSaveInstanceState(), but that won't help me.

我注意到,一些视频播放器的应用程序不断改变屏幕方向时播放视频。难道我的活动运行到同样保持?我不希望我的计时器停止运行,当用户倾斜他们的电话。

I notice that some video player apps continue to play video during screen orientation change. Is it possible to similarly keep my activity running? I don't want my timer to stop running when the user tilts their phone.

这是如何解决这一问题的任何想法? (除了固定的屏幕方向)

Any ideas on how to fix this? (apart from fixing the screen orientation)

谢谢!

推荐答案

您应该使用后台服务的计时器,所以它不会对方向变化停止。

You should use a background service for the timer, so that it doesn't stop on orientation change.

这篇关于安卓:协助处理屏幕方向变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆