android.view.WindowManager $ BadTokenException:无法添加窗口无效;你的活动在运行吗?

时间:2017-03-21 03:10:12

标签: android

我尝试在我的活动中添加对话框,但是徒劳无功, 以下是我的代码。

    private void saveMissionFile() {
    final String defaultFilename = TextUtils.isEmpty(openedMissionFilename)
            ? FileStream.getWaypointFilename("waypoints")
            : openedMissionFilename;

    final SupportEditInputDialog dialog = SupportEditInputDialog.newInstance(MISSION_FILENAME_DIALOG_TAG,
            getString(R.string.label_enter_filename), defaultFilename, true);
 //       dialog.show(getSupportFragmentManager(), MISSION_FILENAME_DIALOG_TAG);

    dialog.show(MyFirstPlanFirstActivity.this.fragmentManager, MISSION_FILENAME_DIALOG_TAG);


}

在我实施应用程序后,我收到此错误而不是应用程序崩溃,我该怎么办?

FATAL EXCEPTION: main android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@6ba556f is not valid; is your activity running?
                                                                                    at android.view.ViewRootImpl.setView(ViewRootImpl.java:679)
                                                                                    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                                                                                    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
                                                                                    at android.app.Dialog.show(Dialog.java:322)
                                                                                    at android.support.v4.app.DialogFragment.onStart(DialogFragment.java:406)
                                                                                    at android.support.v4.app.Fragment.performStart(Fragment.java:1986)
                                                                                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
                                                                                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
                                                                                    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                                                                                    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
                                                                                    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
                                                                                    at android.os.Handler.handleCallback(Handler.java:751)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                    at android.os.Looper.loop(Looper.java:154)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

0 个答案:

没有答案