Tuesday, May 8, 2018

How to Close/Exit Android Application Programmatically

// ADD THE FOLLOWING CODE IN YOUR FIRST JAVA ACTIVITY

Change the playstore url to yours, 

 com.kenyawhatsappgroups.links to your package name 

CategoriesActivity to your first category


@Overridepublic void onBackPressed() {
    new android.app.AlertDialog.Builder(this)
            .setMessage("would you please show some love by rating us 5 stars on playstore?")
            .setCancelable(false)
            .setPositiveButton("yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    final Uri marketUri = Uri.parse("https://play.google.com/store/apps/details?id=com.kenyawhatsappgroups.links");
                    startActivity(new Intent(Intent.ACTION_VIEW, marketUri));
                }
            })

            .setNegativeButton("no", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    com.kenyawhatsappgroups.links.CategoriesActivity.this.finish();


                    finish();
                }
            })                .show();
}

post written by:

Related Posts