There is 2 activities in my project. I want to call a new activity when press the back button. I tried both onBackPressed(),onKeyDown() for that. My code is given below. I searched for this in google but nothing worked for me.
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
Log.d("update", is_updated.toString());
if(is_updated){
Intent i = new Intent(ProductDetailsActivity.this,ProductListActivity.class);
startActivity(i);
finish();
is_updated = false;
}else {
finish();
}
}
I logged the value "is_update", even the value is "true" Its not calling the ProductListActivity.class, The same code is working for button click.How I can call the new activity in onBackpressed(), Can anyone help me.