onrestoreinstancestate

Fragments restore state on orientation changed

无人久伴 提交于 2019-12-01 15:10:28
问题 I have to implement "standart" fragments navigation in my app (please see link). The issue is when device is in portrait mode, there should be shown only 1 fragment, and when it is rotated to landscape mode, 2 fragments should be shown. I tried to do this 2 different ways: 1) I use only 1 activity with different portrait and landscape layouts. Portrait layout xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android

How to simulate killing activity to conserve memory?

守給你的承諾、 提交于 2019-11-29 02:50:53
Android doc say: "When the system, rather than the user, shuts down an activity to conserve memory, ... " But how to simulate this situation?I want to debug the onRestoreInstanceState(Bundle) method,but don't know how to. numan salati You can't do it in an automated way b/c its completely non deterministic. See my answer here: https://stackoverflow.com/a/15048112/909956 for details. But good news is that all you need to do is just simulate calling onSaveInstanceState and you are indirectly testing this low memory situation. onSaveInstanceState can be triggered by: losing focus (by pressing

How to simulate killing activity to conserve memory?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 21:59:23
问题 Android doc say: "When the system, rather than the user, shuts down an activity to conserve memory, ... " But how to simulate this situation?I want to debug the onRestoreInstanceState(Bundle) method,but don't know how to. 回答1: You can't do it in an automated way b/c its completely non deterministic. See my answer here: https://stackoverflow.com/a/15048112/909956 for details. But good news is that all you need to do is just simulate calling onSaveInstanceState and you are indirectly testing

when is onRestoreInstanceState called?

独自空忆成欢 提交于 2019-11-27 07:46:40
Sorry for my incomprehension, but I am new in the android development. I have an application with activity A and activity B in it, and I go from activity A to activity B. When I left activity A, the onSaveInstanceState method was called, but when I went back to activity A (from activity B in the same application), the bundle in the onCreate method was null. What can I do, to save the activity A's previous state? I only want to store the data for the application lifetime. Can someone help me with this? Here is my code for Activity A: @Override protected void onCreate(Bundle savedInstanceState)

when is onRestoreInstanceState called?

三世轮回 提交于 2019-11-26 13:49:13
问题 Sorry for my incomprehension, but I am new in the android development. I have an application with activity A and activity B in it, and I go from activity A to activity B. When I left activity A, the onSaveInstanceState method was called, but when I went back to activity A (from activity B in the same application), the bundle in the onCreate method was null. What can I do, to save the activity A's previous state? I only want to store the data for the application lifetime. Can someone help me