aspel
aspel

Reputation: 71

Android finish activity and reload the previously activity

I have activities A -> B -> C.
I finish the activity C and when it destroyed I want automatically reload the activity B.

Help pls.

Upvotes: 3

Views: 7210

Answers (3)

Hoang
Hoang

Reputation: 11

If u opened Activity A->B->C

You can use something like:

use finish(); on Activity C

and use

@Override
protected void onRestart() {
    super.onRestart();
    reloadDATABASE();
}

on Activity B

Activity C will close and Activity B will reload its DATABASE

u can use the same method to close Activity B and reload Activity A

Upvotes: 1

Balaji Khadake
Balaji Khadake

Reputation: 3479

Why you want to reload because actually activity B is already there in stack. So, just simply call closeActivity() on Activity C and your activity B will be resumed.

Upvotes: -2

Natan
Natan

Reputation: 2858

You may start activity C with the following.

startActivityForResult(new Intent(Intent.C, 0);

Then, when C is finished you may do whatever you want with the following:

protected void onActivityResult(int requestCode, int resultCode,
         Intent data){
     reload();
     //OR
     startActivity(new Intent(Intent.B,0);
}

Check here: http://developer.android.com/reference/android/app/Activity.html#StartingActivities

Upvotes: 12

Related Questions