避免重新启动的方向变化线程 [英] Avoid restarting threads on orientation change

查看:142
本文介绍了避免重新启动的方向变化线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有我的活动的OnCreate()方法中的一些线程。当方向改变线程再次重新启动(线程的新实例被每个方向变化所造成的)。

There are some threads in my activity's oncreate() method. When the orientation changes the threads are restarting again (new instance of threads gets created on every orientation change).

我不希望使用安卓configChanges 安卓screenOrientation 。由于活动是取向相关。

I don't want to use android:configChanges or android:screenOrientation. Because the Activity is orientation dependent.

推荐答案

使用安卓configChanges ,但在overrided onConfigurationChanged()方法只调用 super.onConfigurationCanged()方法(或不重写,通常情况下)。

Use android:configChanges, but in overrided onConfigurationChanged() method only call super.onConfigurationCanged() method (or don't override it, generally).

在旋转的onCreate时间()不被调用,您的胎面无法重新启动,但您的布局将旋转。

In time of rotation onCreate() not be called and your treads not be restarted, but your layout will be rotate.

这篇关于避免重新启动的方向变化线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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