Android Refresh activity when returns to it

You should handle the result of activity that you started with "startActivityForResult" in a parent activity in a method:

@override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
   //...
}

And depending on result you could just invoke again a code that is responsible for showing the information in your parent activity (may be you put it into onResume() method or like that).

I would suggest you to move all the logic responsible for information rendering to a separate method. And invoke it after you recieve the result. Instead of restarting your parent activity.


on button press:

Intent intent = new Intent(this, SyncActivity.class);
        //intent.putExtra("someData", "Here is some data");
        startActivityForResult(intent, 1);

Then in the same Activity class:

   @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(resultCode==RESULT_OK){
         Intent refresh = new Intent(this, InitialActivity.class);
         startActivity(refresh);
         this.finish();
      }
     }

The Sync Activity would have:

setResult(RESULT_OK, null);
finish();

Another tricky way to do this is just start your activity on onRestart()

@Override
public void onRestart(){
    super.onRestart();
    Intent previewMessage = new Intent(StampiiStore.this, StampiiStore.class);
    TabGroupActivity parentActivity = (TabGroupActivity)getParent();
    parentActivity.startChildActivity("StampiiStore", previewMessage);
    this.finish();
}

That should do the trick actually. (In this code I'm showing the way it's done when you are using a custom TabActivity manager.)