相关疑难解决方法(0)

buider.show()上的"android.view.WindowManager $ BadTokenException:无法添加窗口"

从我的主要activity,我需要调用内部类和类中的方法,我需要显示AlertDialog.解除后,按下确定按钮后,转发到Google Play进行购买.

在大多数情况下,事情完美无缺,但对于少数用户而言,它正在崩溃builder.show(),我可以看到"android.view.WindowManager$BadTokenException:无法在崩溃日志中添加窗口.请建议.

我的代码非常像这样:

public class classname1 extends Activity{

  public void onCreate(Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.<view>); 

    //call the <className1> class to execute
  }

  private class classNamename2 extends AsyncTask<String, Void, String>{

    protected String doInBackground(String... params) {}

    protected void onPostExecute(String result){
      if(page.contains("error")) 
      {
        AlertDialog.Builder builder = new AlertDialog.Builder(classname1.this);
        builder.setCancelable(true);
        builder.setMessage("");
        builder.setInverseBackgroundForced(true);
        builder.setNeutralButton("Ok",new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton){
            dialog.dismiss();
            if(!<condition>)
            {
              try
              {
                String pl = ""; 

                mHelper.<flow>(<class>.this, SKU, RC_REQUEST, 
                  <listener>, …
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog

107
推荐指数
3
解决办法
11万
查看次数

标签 统计

android ×1

android-alertdialog ×1