【问题标题】:How to customize the Uninstall alert Dialog?如何自定义卸载警报对话框?
【发布时间】:2014-04-29 19:01:06
【问题描述】:

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

我用过以下sn-ps,

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

卸载警报已打开并且卸载正常。但我想自定义卸载警报对话框。该怎么做?

【问题讨论】:

  • 我认为该对话框是 Android 的一部分。您可能无法更改它。
  • 其实你不需要这样做。这项工作将由 android ..j 完成

标签: java android android-alertdialog uninstallation


【解决方案1】:

可以从这段代码中尝试.......................

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();


}

【讨论】:

  • 如果我这样做意味着再次打开默认对话框,因为您使用的是相同的 Intent sn-ps :-(。如果有任何其他选项,请建议我
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多