Call OnCreate by pressing the backbutton
Hy!
M开发者_如何学编程y code:
if(keyCode == KeyEvent.KEYCODE_BACK)
{
if (menuestate == 1)
Main.this.onCreate(null);
}
}
if i press the backbutton i see the oncreate for a half second an then the homescreen occur
Whats wrong?
This is not how it is supposed to work. If you want to restart your activity you need to call finish() and then restart it through the Intent, like this:
if(keyCode == KeyEvent.KEYCODE_BACK)
{
if (menuestate == 1)
finish();
Intent intent = new Intent(Main.this, Main.class);
startActivity(intent);
}
}
精彩评论