i'm trying to intent from my activity to activity with fragment. the intent is ok but what i want it is when it intent it will automatically call the fragment2 based on what it clicked in previous activity. i'm tring to make intent with getExtra to make if in activity of fragment to make if the id is 1 then call the fragment with the code below:
String sessionId2;
String id = null;
String sessionId = getIntent().getStringExtra("baik");
sessionId2 = getIntent().getStringExtra("diperbaiki");
String sessionId3 = getIntent().getStringExtra("rusak");
Log.d("baik",""+sessionId);
Log.d("diperbaiki",""+sessionId2);
Log.d("rusak",""+sessionId3);
if (id == sessionId3) {
TabLayout.Tab tab = tabLayout.getTabAt(1);
tab.select();
}else if (id == sessionId2) {
TabLayout.Tab tab = tabLayout.getTabAt(2);
tab.select();
}
but it still not working. and i also try to change the position like the code below:
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
if (id == sessionId2){
position = 1;
}
switch (position) {
case 0:
// Top Rated fragment activity
return new BaikFragment();
case 1:
// Games fragment activity
return new DiperbaikiFragment();
case 2:
// Movies fragment activity
return new RusakFragment();
}
return null;
}
but it wont work too. please help is there is any idea?