모바일 NetWork 상태를 알아 볼려고 합니다.

Dialog 를 UtilDialog  클래스를 만들어서 Dialog를 사용 할려고 합니다.

 

int netWork = UtilDeviceInfo.getAvailableNetwork(context);
  if(netWork == 1){
   Toast.makeText(getApplicationContext(), "3G 상태 입니다.", Toast.LENGTH_LONG).show();
   UtilDialog popup1 = new UtilDialog(m_oActivity);
   popup1.createTwoButtonDialog("모바일 네트워크 상태 입니다.", "3G 상태 입니다.", "확인", "취소"
     , m_oReportListener, m_oReportListener, true).show();
   
  }

 

예상 오류는 여기서 나는것 같은데요...

UtilDialog class

 Builder mMessageBuilder = null;

mMessageBuilder = new AlertDialog.Builder(mContext);

public AlertDialog createTwoButtonDialog(String a_sTitle, String a_sMessage, String a_sPositiveStr, String a_sNegativeStr,
            DialogInterface.OnClickListener a_oOKClickListener, DialogInterface.OnClickListener a_oNOClickListener, boolean a_bIsCustom)
    {
  
      mMessageBuilder.setCustomTitle(createCustomView(a_sTitle));
      mMessageBuilder.setView(createCustomView(a_sMessage));

mMessageBuilder.setPositiveButton(a_sPositiveStr, a_oOKClickListener);
        mMessageBuilder.setNegativeButton(a_sNegativeStr, a_oNOClickListener);

        return mMessageBuilder.create();

 

}

private View createCustomView(String a_sText)
    {
     LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
     View mDialogLayout = mInflater.inflate(R.layout.customalert, null);
     TextView oTextView = null;
     
     if(mDialogLayout != null)
     {
      oTextView = (TextView)mDialogLayout.findViewById(R.id.text);
      oTextView.setText(a_sText);
     }
     
     return mDialogLayout;
    }

 

 

오류 내용

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tabgroup/com.tabgroup.TabMainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tabgroup/com.ionman.activity.TabGroup1}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tabgroup/com.ionman.MainHomeActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4052e9c8 is not valid; is your activity running?

 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1668)

 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1684)

 at android.app.ActivityThread.access$1500(ActivityThread.java:117)

 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:952)

 at android.os.Handler.dispatchMessage(Handler.java:99)

 at android.os.Looper.loop(Looper.java:130)

 at android.app.ActivityThread.main(ActivityThread.java:3704)