android.view.WindowManager $ BadTokenException:无法添加窗口 - 令牌android.app.LocalActivityManager $ LocalActivityRecord

时间:2014-09-26 06:44:03

标签: java android tabview activitygroup activity-manager

我有两个类phone.java和dialpad.java在手机类中有5行,当我点击这些行时,拨号盘活动已打开。这些类在单个选项卡中,所以我使用ActivityGroup.In拨号盘有一个转移按钮,当你点击转移按钮时,对话框将打开并加入线。我面临的问题是当我点击转移按钮时应用程序崩溃和显示这个错误..

09-26 10:59:29.506: E/AndroidRuntime(4548): FATAL EXCEPTION: main
09-26 10:59:29.506: E/AndroidRuntime(4548): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4188e348 is not valid; is your activity running?
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.ViewRootImpl.setView(ViewRootImpl.java:689)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:313)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.Window$LocalWindowManager.addView(Window.java:537)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.app.Dialog.show(Dialog.java:278)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at com.vax.dev.lib.DialPad$4.onClick(DialPad.java:169)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.View.performClick(View.java:3627)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.view.View$PerformClick.run(View.java:14304)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.os.Handler.handleCallback(Handler.java:605)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.os.Looper.loop(Looper.java:137)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at android.app.ActivityThread.main(ActivityThread.java:4512)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at java.lang.reflect.Method.invokeNative(Native Method)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at java.lang.reflect.Method.invoke(Method.java:511)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
09-26 10:59:29.506: E/AndroidRuntime(4548):     at dalvik.system.NativeStart.main(Native Method)

帮我解决这个问题。

Dialpad.java

public class DialPad extends ActivityGroup {
    private static String[] m_objPhoneNum = new String[VaxSIPUserAgent.TOTAL_LINE_COUNT];

    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialer);

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        Phone.m_objDialPad = this;

        m_objStatus = (TextView) findViewById(R.id.DialerStatus);

        Intent intent = getIntent();

        int nIntentExtraLineNo = intent.getIntExtra("LineNo", 1);
        m_nLineNo = nIntentExtraLineNo;

        final int[] aLineArray = new int[VaxSIPUserAgent.TOTAL_LINE_COUNT - 1];

        int nIndex = 0;

        for (int nLineNo = 0; nLineNo < VaxSIPUserAgent.TOTAL_LINE_COUNT; nLineNo++) {
            if (m_nLineNo == nLineNo)
                continue;

            aLineArray[nIndex] = nLineNo + 1;
            nIndex++;

        }

        m_objBtntransfer.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {

                final Dialog dialog = new Dialog(DialPad.this, android.R.style.Theme_Translucent);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.transfer);
                dialog.setTitle("Transfer Call");
                dialog.show();

                m_objline2 = (TextView) dialog.findViewById(R.id.line2);
                m_objline3 = (TextView) dialog.findViewById(R.id.line3);
                m_objline4 = (TextView) dialog.findViewById(R.id.line4);
                m_objline5 = (TextView) dialog.findViewById(R.id.line5);
                m_objBlindTransferEditText = (EditText) dialog.findViewById(R.id.BlindTransferEditText);

                m_objBtnBlindTransfer = (Button) dialog.findViewById(R.id.BlindTransferBtn);

                m_ConsultTransferBtn1 = (Button) dialog.findViewById(R.id.TransferBtn1);
                m_ConsultTransferBtn2 = (Button) dialog.findViewById(R.id.TransferBtn2);
                m_ConsultTransferBtn3 = (Button) dialog.findViewById(R.id.TransferBtn3);
                m_ConsultTransferBtn4 = (Button) dialog.findViewById(R.id.TransferBtn4);

                m_objline2.setText("Line | " + aLineArray[0]);
                m_objline3.setText("Line | " + aLineArray[1]);
                m_objline4.setText("Line | " + aLineArray[2]);
                m_objline5.setText("Line | " + aLineArray[3]);

                m_objBtnBlindTransfer.setOnClickListener(new OnClickListener() {
                    public void onClick(View arg0) {
                        if (m_objBlindTransferEditText.length() == 0)
                            return;

                        if (VaxPhone.m_objVaxVoIP.IsLineConnected(m_nLineNo) == false)
                            return;

                        String sToUserName = m_objBlindTransferEditText.getText().toString();

                        boolean val = VaxPhone.m_objVaxVoIP.TransferCallEx(m_nLineNo, sToUserName);
                        dialog.cancel();
                    }
                });

                m_ConsultTransferBtn1.setOnClickListener(new OnClickListener() {
                    public void onClick(View arg0) {
                        if (VaxPhone.m_objVaxVoIP.IsLineConnected(m_nLineNo) == false)
                            return;

                        boolean val = VaxPhone.m_objVaxVoIP.JoinTwoLine(aLineArray[0] - 1, m_nLineNo);
                    }
                });

                m_ConsultTransferBtn2.setOnClickListener(new OnClickListener() {
                    public void onClick(View arg0) {
                        if (VaxPhone.m_objVaxVoIP.IsLineConnected(m_nLineNo) == false)
                            return;

                        boolean val = VaxPhone.m_objVaxVoIP.JoinTwoLine(aLineArray[1] - 1, m_nLineNo);

                    }
                });

                m_ConsultTransferBtn3.setOnClickListener(new OnClickListener() {

                    public void onClick(View arg0) {
                        if (VaxPhone.m_objVaxVoIP.IsLineConnected(m_nLineNo) == false)
                            return;

                        boolean val = VaxPhone.m_objVaxVoIP.JoinTwoLine(aLineArray[2] - 1, m_nLineNo);

                    }
                });

                m_ConsultTransferBtn4.setOnClickListener(new OnClickListener() {
                    public void onClick(View arg0) {
                        if (VaxPhone.m_objVaxVoIP.IsLineConnected(m_nLineNo) == false)
                            return;

                        boolean val = VaxPhone.m_objVaxVoIP.JoinTwoLine(aLineArray[3] - 1, m_nLineNo);

                    }
                });
            }
        });

    }
}

0 个答案:

没有答案