I created TabActivity having two tabs with two activities.
one is login tab another is welcome tab.
user should not go welcome tab unless login successfully.if he tries to select welcome tab he throws to login tab.i use tabHost.setcurrenttab(index).
But when i click direct welcome tab it works fine for first time. When i again click tab rapidly it opens welcome tab.
Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.product_list);
SharedPreferences mPreference = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
username = mPreference.getBoolean("valid", false);
Toast.makeText(this, "In Create", Toast.LENGTH_SHORT).show();
//login sucessful
tabActivity.switchTab(0);
}
on onResume, i repeat the same code.
Try this in your TabActivity. This is to prevent user to switch tab if he is not logged in.(I have no time to check it now,please let me know if any issue is there with the code):