My app isn't closing correctly and I'm not sure why
First off, I'm using the Action Bar. When I go back to my Main class after pressing the Home option, then press the Back button, my app won't close like it should. Instead, it tries to open the activity it left from, but since I'm calling finish(), it just animates like it's switching activities and then shows my Main class. After this, I can press the Back button and properly close the app. If I don't press the Home option and use the Back button from my second activity, everything works like it should.
Intent leading back to my Main class.
@Override
public boolean onOptionsItemSelect开发者_JS百科ed(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = new Intent(First.this, Second.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
finish();
}
return super.onOptionsItemSelected(item);
}
Try using intent.addflags(flags) not using intent.setflags(flags)...!!!!!
精彩评论