从通知导航到选项卡片段

时间:2014-03-07 09:47:43

标签: android android-fragments

我想从通知中导航到TabHost中的细节片段。这是代码不工作。 我试过onResume和onStart。这是正确的吗?

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent() != null && getIntent().getExtras() != null) {
        msgFromNotification = getIntent().getExtras().getParcelable("message");
    } else {
        msgFromNotification = null;
    }
.
.
.
}

enter code here


    @Override
protected void onResume() {
    super.onResume();
    if (msgFromNotification != null) {
        navigateToDetail(msgFromNotification);
    }
}

public void navigateToDetail(ACMessage msg) {
    msg.setReaded(true);
    InboxDetailMessageFragment frDetail = new InboxDetailMessageFragment();
    frDetail.setMsg(msg);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    ft.setCustomAnimations(R.anim.left_to_rigth, R.anim.right_to_left, R.anim.left_to_rigth_out, R.anim.right_to_left_out);
    ft.add(R.id.realtabcontent, frDetail);
    ft.addToBackStack(null);
    ft.commit();
}

0 个答案:

没有答案