如何自定义卸载警报对话框?

时间:2014-03-22 08:24:35

标签: java android alertdialog uninstall

我正在开发一个Android应用程序。在那个应用程序中,我想卸载一个应用程序我的应用程序。

我使用了以下代码段

Intent intent = new Intent(Intent.ACTION_DELETE);
                  intent.setData(Uri.parse("package:" +     ((ResolveInfo)list.get(position)).activityInfo.packageName));
                 c.startActivity(intent);

卸载警报已打开,卸载完成。但我想自定义卸载警报对话框。怎么做?

1 个答案:

答案 0 :(得分:0)

可以尝试使用此代码................................

public void btFirst(View v) {

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

    // set title
    alertDialogBuilder.setTitle("ALERT>>>>>");

    // set dialog message
    alertDialogBuilder
        .setMessage("UNINSTALL")
        .setCancelable(false)
        .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {
                // if this button is clicked, close
                // current activity
                Uri packageURI = Uri.parse("package:com.example.pp");
                Intent intent = new Intent(Intent.ACTION_DELETE, packageURI);
                startActivity(intent);      

                //MainActivity.this.finish();
            }
          })
        .setNegativeButton("No",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {
                // if this button is clicked, just close
                // the dialog box and do nothing
                dialog.cancel();
            }
        });

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();


}
相关问题