Create About Dialog - Android android.app

Android examples for android.app:AlertDialog

Description

Create About Dialog

Demo Code

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;

public class Main{

    public static AlertDialog getAboutDialog(final Activity activity) {
        String message = "This app was made by @yourName. \n\n"
            + "If you have any feedback, requests or complaints, please let me know!.";

        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        builder.setTitle("About")
                //
                .setIcon(android.R.drawable.ic_dialog_info)
                //
                .setMessage(message)//from   w  ww  .ja va2 s .  c  o  m
                //
                .setCancelable(false)
                //
                .setPositiveButton("Send Feedback",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent intent = new Intent(
                                        android.content.Intent.ACTION_SEND);
                                intent.setType("plain/text");
                                intent.putExtra(
                                        android.content.Intent.EXTRA_EMAIL,
                                        new String[] { "yourname@gmail.com" });
                                intent.putExtra(
                                        android.content.Intent.EXTRA_SUBJECT,
                                        "Feedback on Android App");
                                activity.startActivity(intent);
                            }
                        })
                .setNegativeButton("Close",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                dialog.dismiss();
                            }
                        });
        return builder.create();
    }

}

Related Tutorials