2016-09-29 6 views
1

私はプッシュ通知 私はそれをリダイレクトすることができませんをクリックした後、特定のタブにフォーカスを設定しようとしています、ここに私のコードオープン特定のタブは

Intent intent_chat=new Intent(this, HomeChatFragment.class); 
pendingIntent=PendingIntent.getActivity(this,0,intent_chat,PendingIntent.FLAG_UPDATE_CURRENT); 

ある指導の任意の種類は次のようになりますまことにありがとうございます!

+0

特定のタブはどういう意味ですか? – Nikhil

+0

@indramurariホーム画面に4つのタブがありますが、プッシュをクリックするとチャットタブ(3番目のタブ)にリダイレクトされます – rookieDeveloper

+0

インテントからフラグを送信して、特定のフラグを取得している場合特定のタブを開く – Nikhil

答えて

2
Intent intent_chat=new Intent(this, HomeChatFragment.class); 
intent.putExtra("someFlag", 2); //tab position to open 
pendingIntent=PendingIntent.getActivity(this,0,intent_chat,PendingIntent.FLAG_UPDATE_CURRENT); 

とあなたのHomeChatFragment.javaでこれを行う:

selectionTab = bundle.getInt("selectionTab"); 
    tabLayout.getTabAt(selectionTab).select();     
tabLayout.getTabAt(selectionTab).getCustomView().setSelected(true); 
+0

は魅力的に機能します – rookieDeveloper

0

をあなたは活動&でそのフラグを取得し、バンドルを使用することによって意図&から同様のtablayoutに設定し、いくつかのフラグを送ることができますそれはあなたの問題を解決することができます。試してみてください

Intent intent = new Intent(this, MainActivity.class); 

    intent.putExtra(UtilityConstants.key, value); 

    PendingIntent contentIntent = PendingIntent.getActivity(this, _id, 
      intent, PendingIntent.FLAG_CANCEL_CURRENT); 

質問がありましたら、ここにコメントしてください!

0

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     ... 
     ... 
     int i; 
     if(getIntent() != null) { 
      i = getIntent().getIntExtra("someFlag", -1); 
     } 
     if(i != -1) { 
      yourViewPager.setCurrentItem(i); 
     } 
    } 
関連する問題