The first activity is called after having survived the background

advertisements

In my application, I am finishing my first activity when I move to the next activity like this:

if(className.equals("com.tritonhk.android.LoginActivity"))
            startActivityForResult(in, 1);
        //loadingrelative.setVisibility(View.GONE);
        displayVal = 0;
        Helper.IsFullSync = false;
        LoginActivity.this.finish();

So that when I go in background from any other activity and come back in foreground then that activity must be called by which we went in background.

It is happening in some cases but If I remain in background for more then 10 minutes then my first activity's oncreate method is called.

It seems that dalvik is killing my application process that is why when I click on my application icon then its new instance is created and hence its onCreate is called.

Please suggest me what should be the better approach for this.

EDIT Problem solved partially. Now with android:launchMode = "standard" behaves normally but not in first attempt. I mean when I install the app and run it and went to background and come back to foreground then it does not work but from the second time it works properly.


Do u have android:launchMode="standard" for the activity which is called while launching the app? If not add this line.