Note that there are some explanatory texts on larger screens.

plurals
  1. POAvoid destroying of activity
    text
    copied!<p>I have a main activity from which the user starts several activities with <code>startActivityForResult</code> . This might be an external application like the xing barcode scanner or a internel activity like a mapview or calendar ect.</p> <p>The Problem is, by executing <code>startActivityForResult</code> my main activity is paused and might be terminated by the android system. Somtimes, when the user stay a long time in a started activity this happens and after closing the new activity the main activity is destroyed and the OnActivityResult Listener is not called.</p> <p>Is there a way to tell the system "Do not destroy this paused activity" ?</p> <blockquote> <p>edit:</p> </blockquote> <p>The Problem is a little bit more complicated, i fear i've made many mistakes in the whole achitecture of my app. I will try to explain what i've done:</p> <p>I have a main activity (<code>extends TabActivity</code>) and a <code>final public class GlobalVars</code> in GlobalVars is store lots of Variables or Classes, which are used by all activities of the project eg. :</p> <pre><code>public static boolean system_initialized = false; public static boolean system_Onforeground = true; </code></pre> <p>in the <code>main.class OnCreate</code> Method, i set system_initialized to <code>true</code> in the <code>OnResume</code> method i set <code>Onforeground = true</code> , in <code>onPause</code> is set <code>Onforeground = false</code> and in <code>OnDestroy</code> is set <code>initialized = false</code></p> <p>if I start the app system_initialized and Onforeground will be true, if i start a <code>ActivityforResult</code> initialized will stay true, but Onforeground will be set to false.</p> <p>Now i have a BroatcastReceiver wich starts <code>android.intent.action.BOOT_COMPLETED</code> and initialise a Alamrmmanager with a Service as pendingIntent.</p> <p>Now I use the service to check every minute if i have to do something in the main activity. If a action occured, the services checks if system_initialized = true (in GlobalVars) if not, the service starts the app, otherwise the service use a handler (in GlobalVars) to call a Runnable in the main activity.</p> <p>This works well, if the main Activity is running, the runnable will be executed and something happens, if the user has started a <code>ActivityforResult</code> the service realised that the main activity is not onForeground and do something in the background. But if the main activity is destroyed, the service will restart the main activity and i don't want that ^^</p> <p>I know, quite strange, but i dont know how to realise the things i need in a other way...</p>
 

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