Android - 警告对话框强制关闭

Android - Alert Dialog force close

我想在下面显示警告对话框,但它强制关闭,我对上下文应该是什么感到有点困惑。 单击图像时会显示此对话框。

AlertDialog.Builder builder = new AlertDialog.Builder(
getApplicationContext(), R.style.TitleDialog);
builder.setTitle("Sorry for Inconvinience");
builder.setMessage("You need to install MX Player or VLC Media Player");
AlertDialog alert = builder.create();
alert.show();

我是初学者任何帮助将不胜感激 完整的 onclicklistener

ib2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isInternetPresent) {
                try {
                    startActivity(i2);
                } catch (Exception e) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                    builder.setTitle("Sorry for Inconvinience");
                    builder.setMessage("You need to install MX Player or VLC Media Player, here is the link: ");
                    AlertDialog alert = builder.create();
                    alert.show();

                }
            } else {
                Toast.makeText(getApplicationContext(),
                        "Please check your Internet Connection.",
                        Toast.LENGTH_LONG).show();
            }
        }
    });
  AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
        builder.setTitle("Sorry for Inconvinience");
        buildersetMessage("You need to install MX Player or VLC Media Player");
       .show();

以上代码应该可以工作。 我不知道什么

getApplicationContext(), R.style.TitleDialog);

虽然是用来做的。