Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Restoring the active Activity while resuming the application
    primarykey
    data
    text
    <p>I have two activities running: <em>mainActivity</em> and <em>childActivity</em>. Whenever the user clicks in the button in <em>mainActivity</em>, the <em>childActivity</em> is launched. What I want to do is this:</p> <p>When the active activity is the <em>childActivity</em> and the user <strong>clicks the home button then relaunch the application</strong>, I want to see the <em>childActivity</em> <strong>instead of</strong> <em>mainActivity</em> that is launched. </p> <p>I had some suggestions actually work arounds. I tried to manipulate onStart, onRestart, onResume, onStop, onDestroy events. But, they didn't fully solve the problem. There should be a smart way out there. Thank you.</p> <p>Edit: </p> <p>Thank you for the answer, Soonil. The case you said is happening when the activity is called from recent activities window. (the window opened when you long press the home button) However; This is not happening when you open it from home screen. (like opening from start) I don't think my code has a specific problem to generate this error. Because, I created a test project and tried standalone before sending the question and faced the same problem. Anyhow, here is the test code:</p> <pre><code>public class MainActivity extends Activity implements OnClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.setTitle("MainActivity"); ((Button) findViewById(R.id.btnChildActivity)).setOnClickListener(this); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivity(new Intent(this, ChildActivity.class)); } } public class ChildActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); this.setTitle("ChildActivity"); } } </code></pre>
    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