I want to have a condition for the tab when i backpressed it all goes on Home tab but when i backpressed all the activities end.
here's my code. try to help me.
backpressed = true;
if (results.equals("HOME")) {
mTabHost.setCurrentTab(0);
backpressed = false;
} else if (results.equals("B")) {
mTabHost.setCurrentTab(2);
} else if (results.equals("C")) {
mTabHost.setCurrentTab(3);
} else if (results.equals("D")) {
mTabHost.setCurrentTab(1);
} else if (results.equals("E")) {
singleton.openNewsFeed = true;
mTabHost.setCurrentTab(4);
} else {
singleton.openMessage = true;
mTabHost.setCurrentTab(4);
}
and this is my onBackPressed
@Override
public void onBackPressed() {
/*super.onBackPressed();*/
if (backpressed == true) {
Intent intent = new Intent(getApplicationContext(), Dashboard.class);
intent.putExtra("result", "HOME"); // getText() SHOULD NOT be static!!!
startActivity(intent);
}else{
//FINISH
super.onBackPressed();
}
}