onBackPressed() doesn't work for me

后端 未结 1 355
眼角桃花
眼角桃花 2021-01-26 13:13

I have a problem, which is also discussed here: onBackPressed never gets called

I\'m trying to cancel a CountDownTimer when pressing the native back button from an andro

相关标签:
1条回答
  • 2021-01-26 13:41

    the onBackPressed should be in the main activity class

    Also try to specify the parent and child activities in the manifest file of the app e.g

    android:parentActivityName
    

    and try to use something like this and rebuild your App

    @Override 
    public void onBackPressed() {
    super.onBackPressed();
    i = new Intent(CurrentActivity.this, NextActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    startActivity(i);
    finish();
    } 
    

    if it still doesn't work try to make a new application and import your files

    0 讨论(0)
提交回复
热议问题