Android Refresh Activity When Returns To It
Solution 1:
Another tricky way to do this is just start your activity on onRestart()
@OverridepublicvoidonRestart(){
super.onRestart();
IntentpreviewMessage=newIntent(StampiiStore.this, StampiiStore.class);
TabGroupActivityparentActivity= (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.)
Solution 2:
You should handle the result of activity that you started with "startActivityForResult" in a parent activity in a method:
@overridepublicvoidonActivityResult(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.
Solution 3:
If you start your second activity with the method startActivityForResult
, when you return to the first activity, onActivityResult
of the first activity will be called.
If you override it, you can refresh your activity from there.
Solution 4:
Call child activity using startActivityForResult with request code,SetResult from the child Activity. And when the child activity is finished, you can update you parent activity in onActivityResult method
@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stubsuper.onActivityResult(requestCode, resultCode, data);
//Check the result and request code here and update ur activity class
}
Here is an example http://rahulonblog.blogspot.com/2010/05/android-startactivityforresult-example.html
Solution 5:
Override onRestart()
method inside activity you want to refresh, and recreate the activity
@OverrideprotectedvoidonRestart() {
super.onRestart();
this.recreate();
}
Post a Comment for "Android Refresh Activity When Returns To It"