0

I have an activity that runs asynctasks among other things, I don't want everything to be reset when the layout changes.

I put this in the activity's manifest element android:configChanges="orientation" but unfortunately the activity doesn't even switch from the landscape to portrait layout anymore when that is there!

I only halfway understand saveInstanceStates and passing Bundles around, and I'm definitely not sure how to use that with complex data objects, insight appreciated there

What I would like to do is make sure that the asynctasks don't run again, (I could save variables to disk, and do a conditional check for them before running the asynctask) if there is some android way to really watch out for this that would be great!

thanks

4

3 に答える 3

1

このライブラリは間違いなくあなたの目的に役立つと思います

http://brainflush.wordpress.com/2009/11/16/introducing-droid-fu-for-android-betteractivity-betterservice-and-betterasynctask/

于 2011-09-22T01:06:11.440 に答える
0

マニフェストを配置android:configChanges="orientation"すると、Androidが向きの変更を処理する必要がないことを宣言します。したがって、オリエンテーションは決して起こりません。

このスレッドでonConfigurationChange(この場合はorientation)をバンドルするために値を保存する方法を確認できます。Androidアプリケーションの状態を保存するにはどうすればよいですか?

簡単に言うと、をオーバーライドすることで、バンドルする値をいくらか節約できますonSaveInstanceState(Bundle savedInstanceState)。でバンドルパラメータをオーバーライドonRestoreInstanceState(Bundle savedInstanceState)またはチェックして、バンドルに保存した値を取得しますonCreate

于 2011-09-22T00:45:35.890 に答える
0

私は私のために働いているものを投稿することに決めました.これはあなたのように見えますか? これは私のマニフェストからのものです:

<activity android:name=".MediaSelectActivity" 
android:configChanges="orientation|keyboardHidden" 
android:label="Select Media Item for Vision"
 ></activity>
于 2011-09-22T01:07:36.230 に答える