Restarting an activity in a single tab in a TabActivity?

user291701 picture user291701 · Mar 12, 2010 · Viewed 7.7k times · Source

I have a TabActivity. Each tab point to a sub activity. This works great.

Is there any clever way to refresh one of the activity tabs? I just want to 'restart' the activity in tab #3 for example. Not sure of a good way to do this other than building in refresh support to the activity itself, or clearing ALL the tabs and recreating all of them.

Thanks,

Answer

juicedM3 picture juicedM3 · Nov 19, 2011

Slightly more dynamic solution:

LocalActivityManager manager = getLocalActivityManager();
String currentTag = tabHost.getCurrentTabTag();
Class<? extends Activity> currentClass = manager.getCurrentActivity().getClass();
manager.destroyActivity(currentTag, true);
manager.startActivity(currentTag, new Intent(this, currentClass));