Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For primitive values, you should use <code>onSaveInstanceState</code>. For restoring you can use <code>onRestoreInstanceState</code> or you can some code in <code>onCreate</code> like this:</p> <pre><code>if(savedInstanceState != null) { // restore old state } else { // a fresh start } </code></pre> <p>Now for restoring big objects like <code>Bitmap</code> etc if they are not expensive to create and doesn't make your UI sluggish, create them again on restore. If you do not want to that then use <code>onRetainNonConfigurationInstance</code> and code will look like this:</p> <pre><code>@Override public Object onRetainNonConfigurationInstance () { return bmp; } @Override public void onCreate() { bmp = (Bitmap)getLastNonConfigurationInstance(); } </code></pre> <p>WARNING: This api is deprecate, you might use it on old platforms. I put it here for illustration purpose. The new way to do this is more involving. </p> <p>Here is detailed ref:</p> <p><a href="http://developer.android.com/reference/android/app/Activity.html#getLastNonConfigurationInstance%28%29" rel="nofollow">getLastNonConfigurationInstance</a></p> <p><a href="http://developer.android.com/reference/android/app/Activity.html#onRetainNonConfigurationInstance%28%29" rel="nofollow">onRetainNonConfigurationInstance</a></p> <p><strong>Recommended soln for new api levels 11 and above:</strong></p> <p>"Use the new Fragment API setRetainInstance(boolean) instead; this is also available on older platforms through the Android compatibility package." snippet from the doc when you click on the links above. </p> <p>So, you will create your bitmaps inside the fragment and call <code>setRetainInstance</code> on fragment so that fragment and its content (in your case bitmap) will be retained accross config change.</p> <p>Ref:</p> <p><a href="http://developer.android.com/reference/android/app/Fragment.html#setRetainInstance%28boolean%29" rel="nofollow">setRetainInstance</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload