Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Activity lifecycle causing View refresh problems
    primarykey
    data
    text
    <p>I've got a problem in a big project. I'll try to boil it down to what (I hope) are the important points. I have an app that consists of several <code>Activity</code>s, one of which is the main navigation point that the others are launched from. </p> <p>Once the main <code>Activity</code> gets destroyed and recreated (by navigating to another <code>Activity</code> and back), view updates don't seem to work. Specifically, I have a <code>Button</code> and several <code>TextView</code>s. After the <code>Activity</code> is recreated, I can't change their text. I've tried changing the <code>Activity</code> background color, and that doesn't work, either.</p> <p>My first thought was that I missed an important data member during the save/restore process. However, I've looked at that quite a bit, and I think that's not the problem. Also, I've tried not loading the saved data and starting fresh and it still doesn't update the views.</p> <p>Next, I considered that I might not be updating on the UI thread. I'm certain that causes an exception, but to be sure, I posted refreshes to <code>Handler</code>. Still no dice.</p> <p>I can, however, get limited UI changes visible if I wire them to an <code>onClick()</code>. What works and what doesn't in that case raises other questions (some of the data is corrupted), so right now that's where I'm concentrating my investigation. I'll provide an update once I get more of that mapped out. </p> <p>What else should I be looking at?</p> <p>UPDATE: Adding some snippets:</p> <p>From <code>onCreate()</code>:</p> <pre><code>if (savedInstanceState != null) { Log.v(Calculations.log, "Restarting with saved instance state"); Serializable ser = savedInstanceState.getSerializable("infusion"); if ((ser != null) &amp;&amp; (ser instanceof Infusion)) { mInfusion = (Infusion) ser; } mBeganEditing = savedInstanceState.getBoolean("editing", mInfusion != null); Log.v(Calculations.log, this.toString()); } </code></pre> <p>and its matching <code>onSaveInstanceState()</code>:</p> <pre><code>@Override protected void onSaveInstanceState(Bundle outState) { Log.v(Calculations.log, "StageInfusion::onSaveInstanceState()"); Log.v(Calculations.log, this.toString()); outState.putSerializable("infusion", mInfusion); outState.putBoolean("editing", mBeganEditing); outState.putBoolean("resume", true); ServerManager.stopListening(); super.onSaveInstanceState(outState); } </code></pre> <p>I expect that there are other members that should be saved, but they're of minor consequence.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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