对处理转动android感到困惑

时间:2012-03-14 02:29:58

标签: android

学习android编程,我最近发布了一个问题,这有助于我解决问题,但是我仍然无法解决问题。

问题是,每次我转动我的机器人,我的应用程序几乎死了。

以下是发生的事情: 我有onTouchEvent,可以在触摸屏幕的任何时候打印(这是在我转动平板电脑之前):

03-13 22:26:04.544: D/DEBUG(4084): onTouchEvent(MotionEvent{5a481bc0 action=1 x=314.0 y=506.0 pressure=0.0 size=0.0})
And this happens right after I turn the tablet:
03-13 22:26:07.059: D/sensors(1873): input_event iev->type:1 iev->code:101 iev->value:5 
03-13 22:26:07.059: E/WindowOrientationListener(1873): georgezhou++++++++=- onSensorChanged, rotation = 0
03-13 22:26:07.064: D/sensors(1873): hardware/libhardware/modules/sensors/sensors.cpp::data_poll 
03-13 22:26:07.089: E/WindowManager(1873): computeNewConfigurationLocked
03-13 22:26:07.089: I/ActivityManager(1873): Config changed: { scale=1.0 imsi=0/0 loc=md_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=19}
03-13 22:26:07.159: D/DEBUG(4084): Called onStop()
03-13 22:26:07.159: D/DEBUG(4084): Called onDestroy

当我拿到它时打印了'onStop()消息,对于OnDestroy,我的方法首先调用super。,而不是打印消息。

onCreate()实际上有代码创建一个线程,并不断重绘屏幕。 - 我目前不停顿或杀死这个帖子。

为什么没有调用onRestart或onResume? 我没有看到onPause,我期望从http://developer.android.com/guide/topics/fundamentals/activities.html#Lifecycle

这可能很重要,我有这样的设置:minSdkVersion =“4” 那是因为我正在使用Pandigital,这似乎是我能走的最高点。

1 个答案:

答案 0 :(得分:1)

(为了从“未答复”过滤器中删除此问题...)

此处概述了解决方案:

How to handle screen orientation change when progress dialog and background thread active?