Répondre

0

Essayez cette

public void onBackPressed() { 
    showExitAlertBox(); 
} 

public void showExitAlertBox() { 
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); 
    alertDialog.setMessage("You want to quit the play?"); 

    //Yes Quit then go to category page 
    alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int button) { 
      Intent intent = new Intent(getApplicationContext(), PREVIOUSACTIVITY.class); 
      startActivity(intent); 
      finish(); 
     } 

    }); 

    //no Quit stay on same page 
    alertDialog.setNegativeButton("NO", null); 
    alertDialog.show(); 

} 
+0

pas ce que je voulais, mais il travaille avec ceci: http://stackoverflow.com/questions/37039511/how-to-detect-searchviews-back-button-press –

+1

Ce que tu recherches? si cela a fonctionné, cliquez sur la bonne marque –