Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that when you change orientations a new activity is spun up from the beginning (onCreate). Your long running process has a handle to the old (no longer visible) activity. You are properly updating the old activity but since it isn't on screen anymore, you don't see it.</p> <p>This is not an easy problem to fix. There is a library out there that may help you though. It is called DroidFu. Here is a blog post that (much more accurately than I) describes the root cause of what you are seeing and how the DroidFu library combats it: <a href="http://brainflush.wordpress.com/2009/11/16/introducing-droid-fu-for-android-betteractivity-betterservice-and-betterasynctask/" rel="nofollow noreferrer">http://brainflush.wordpress.com/2009/11/16/introducing-droid-fu-for-android-betteractivity-betterservice-and-betterasynctask/</a></p> <p>Edit: (Adding code for tracking active activity)</p> <p>In your application class add this:</p> <pre><code>private Activity _activeActivity; public void setActiveActivity(Activity activity) { _activeActivity = activity; } public Activity getActiveActivity() { return _activeActivity; } </code></pre> <p>In your Activities, add this:</p> <pre><code>@Override public void onResume() { super.onResume(); ((MyApplicationClassName)getApplication()).setActiveActivity(this); } </code></pre> <p>Now you can get the active activity by calling MyApplicationClassName.getActiveActivity();</p> <p>This is not how DroidFu does it. DroidFu sets the active activity in onCreate but I don't feel that is very robust.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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