I want to show an AlertDialog when a user click on Back, Home and Recent button in Android Navigation Bar for back button.
I used onBackPressed() method and it's working fine but for Home and Recent, I am using onPause() method and it's not working.
Kindly help me to resolve it.
@Override
    public void onPause() {
        builder = new AlertDialog.Builder(this);
        builder.setTitle("Alert")
                .setMessage("Do you want to close application?")
                .setCancelable(true)
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        finish();
                    }
                })
                .setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.cancel();
                    }
                })
                .show();
         super.onPause();
    }