2016-10-17 3 views
0

は以下は、ウィンドウを追加することができません - トークンandroid.os.BinderProxy

private void displayInternetAlert(final Context context) { 
     if (!((GlobalActivity) context).isFinishing() && context instanceof GlobalActivity) { 
      ((GlobalActivity) context).runOnUiThread(new Runnable() { 
       @Override 
       public void run() { 
        if (Validator.isNull(internetDialog)) { 
         internetDialog = new AlertDialog.Builder(Util.createCustomAlertDialog(context)).create(); 
         internetDialog.setMessage(context.getString(R.string.internet_disable)); 
         internetDialog.setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.settings), new DialogInterface.OnClickListener() { 
          @Override 
          public void onClick(DialogInterface dialog, int which) { 
       /* 
       Don't need to write onactivity result now as we try to connect every time 
       */ 
           context.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); 
           dialog.dismiss(); 
          } 
         }); 
         internetDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.ignore), new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int which) { 
           dialog.dismiss(); 
          } 
         }); 
         internetDialog.setOnShowListener(new DialogInterface.OnShowListener() { 
          @Override 
          public void onShow(DialogInterface dialog) { 
           internetDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(context.getResources().getColor(R.color.dialog_cancel_button)); 
           internetDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTypeface(null, Typeface.BOLD); 
           internetDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(context.getResources().getColor(R.color.dialog_cancel_button)); 
          } 
         }); 
        } 
        if (!internetDialog.isShowing()) { 
         internetDialog.show(); 
        } 
       } 
      }); 
     } 
    } 

以下は、そこから私のGlobalActivityクラス

public class GlobalActivity extends AppCompatActivity { 
    @Nullable 
    @Bind(R.id.adView) 
    public AdView adView; 

    public GlobalActivity() { 
     ExceptionHandler.getExceptionHandler().setActivity(this); 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { 
     super.onCreate(savedInstanceState, persistentState); 
     setContentView(R.layout.ad_system); 
     ButterKnife.bind(this); 
    } 

    @Override 
    protected void finalize() throws Throwable { 

    } 

    @Override 
    protected void onStart() { 
     super.onStart(); 
     loadGoogleAdd(); 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 
     if(Validator.isNotNull(adView)){ 
      adView.resume(); 
     } 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 
     if(Validator.isNotNull(adView)){ 
      adView.pause(); 
     } 
     Util.setSharedPreferences(this, Util.SHARED_PREFERENCE_PREFERENCES, Util.EXPOSE_GSON.toJson(Util.getPreferences(this))); 

    } 

    private void loadGoogleAdd() { 
     if (adView != null) { 
      AdRequest adRequest = new AdRequest.Builder(). 
        addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
        .build(); 
      adView.loadAd(adRequest); 
     } 
    } 

    public void loadErrorActivity() { 
     startActivity(new Intent(GlobalActivity.this, ErrorActivity.class)); 
    } 

    @Override 
    protected void onDestroy() { 
     super.onDestroy(); 
     if(Validator.isNotNull(adView)){ 
      adView.destroy(); 
     } 
     Request.getRequest().dismissProgressDialog(this); 
    } 
} 

で自分のアプリケーションに警告ダイアログを表示するための私のユーティリティメソッドですIすべての活動を延長しています。そのアクティビティでは、活動の終了を確認しましたが、断片を置き換えています。

しかし、私はまだSM-G935F(Samesung Galaxy s7エッジ)でこの例外を受けています。私はappcompat 23.1.1を使用しています。それはプラットフォームやデバイス固有の問題かどうか、私は間違いを犯しているかどうか、これを解決するために私を助けてください。

助けが必要です。私はそれが可能な仮定法displayInternetAlertと、バックグラウンドスレッドからダイアログを表示するとは思わない

答えて

0

が活動/フラグメントの内側と呼ばれ、あなたはこのように直接ダイアログを表示することができます。

private void displayInternetAlert(final Context context) { 
    if (!((GlobalActivity) context).isFinishing() && context instanceof GlobalActivity) { 
      if (Validator.isNull(internetDialog)) { 
       internetDialog = new AlertDialog.Builder(Util.createCustomAlertDialog(context)).create(); 
       internetDialog.setMessage(context.getString(R.string.internet_disable)); 
       internetDialog.setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.settings), new DialogInterface.OnClickListener() { 
        @Override 
        public void onClick(DialogInterface dialog, int which) { 
     /* 
     Don't need to write onactivity result now as we try to connect every time 
     */ 
         context.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); 
         dialog.dismiss(); 
        } 
       }); 
       internetDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.ignore), new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
         dialog.dismiss(); 
        } 
       }); 
       internetDialog.setOnShowListener(new DialogInterface.OnShowListener() { 
        @Override 
        public void onShow(DialogInterface dialog) { 
         internetDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(context.getResources().getColor(R.color.dialog_cancel_button)); 
         internetDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTypeface(null, Typeface.BOLD); 
         internetDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(context.getResources().getColor(R.color.dialog_cancel_button)); 
        } 
       }); 
      } 
      if (!internetDialog.isShowing()) { 
       internetDialog.show(); 
      } 
     } 
} 
+0

私はすでにrunonuiスレッドを使用してメートル –

関連する問題