Hello all,

I have two activities running: MainActivity and ChildActivity.
Whenever the user clicks in the button in MainActivity, the
ChildActivity is launched. What I want to do is this:

When the active activity is the ChildActivity and the user clicks the
home button then relaunch the application (like opening from the
beginning), I want to see the ChildActivity instead of MainActivity
that is launched. However; This is happening only when the user clicks
from recent activities window. (the window opened when you long press
the home button)

I had some suggestions actually work arounds and 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.

By the way; I don't think my code has a specific problem to generate
this error/feature. Because, I created a test project and tried
standalone before sending the question and faced the same problem.
Anyhow, here is the test code. Thank you.

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");

    }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to