Restart single activity within a tabactivity
As title, I have read some articles. And I wrote this to do so.
public class TabManager {
private static Context tabAct;
private static final String TAG = "TabManager";
public static void setTabActivity(Context t) {
Log.i(TAG, "setTabActivity");
tabAct = t;
}
public static void restart(String tid, Class act) {
Log.i(TAG, "restart " + tid);
LocalActivityManager manager = ((ActivityGroup) tabAct).getLocalActivityManager();
manager.destroyActivity(tid, true);
manager.startActivity(tid, new Intent(tabAct, act));
}
}
However, when I did
开发者_如何学编程TabManager.restart("tid4", MyActivity.class);
The activity was destroyed but it didn't start. Could someone give me some advices? Thanks!
Take a look at the documentation of the LocalActivityManager. It says calling startActivity
will restart the activity if it meets some conditions. So the call to destroyActivity
is not required.
精彩评论