tags:

views:

398

answers:

1

I am writing a application where I am dealing with 4 activities, let's say A, B, C & D. Activity A invokes B, B invokes C, C invokes D. On each of the activity, I have a button called "home" button. When user clicks on home button in any of the B, C, D activities, application should go back to A activity screen ?

How to simulate "home" button in this case ?

+5  A: 
button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        startActivity(new Intent(D.this, A.class));
    }
});

Declare A in your manifest with the android:launchMode="singleTask". This way, when you call startActivity() from your other activies, and A is already running, it will just bring it to the front. Otherwise it'll launch a new instance.

synic
loadActivity is giving compilation error. No such API ??
cppdev
It should be startActivity
cppdev
Whoops, fixed..
synic