在模拟器上运行我的Android应用程序时,有时会出现以下错误:
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: FATAL EXCEPTION: main
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: Process: de.test, PID: 8584
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@f2a625f is not valid; is your activity running?
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.view.ViewRootImpl.setView(ViewRootImpl.java:562)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.app.Dialog.show(Dialog.java:298)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at de.test.plugins.SpinnerAdapterImpl.show(SpinnerAdapterImpl.java:45)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at de.test.plugins.SpinnerAdapterImpl.show(SpinnerAdapterImpl.java:50)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at test.core.plugins.spinner.SpinnerImpl.show(SpinnerImpl.java:20)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at test.core.app.serviceSelection.ServiceSelectionPresenter.segmentSelected(ServiceSelectionPresenter.java:530)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at de.test.app.serviceSelection.ServiceSelectionFragment.tabSelected(ServiceSelectionFragment.java:271)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at de.test.app.serviceSelection.ServiceSelectionFragment.access$000(ServiceSelectionFragment.java:42)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at de.test.app.serviceSelection.ServiceSelectionFragment$1.onTabSelected(ServiceSelectionFragment.java:76)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.support.design.widget.TabLayout.selectTab(TabLayout.java:837)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.support.design.widget.TabLayout.selectTab(TabLayout.java:809)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1077)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.support.design.widget.TabLayout$1.onClick(TabLayout.java:643)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.view.View.performClick(View.java:4780)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:19866)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5257)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-08 05:56:56.331 8584-8584/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
我的代码中引发此错误的最后一行是:ServiceSelectionFragment$1.onTabSelected(ServiceSelectionFragment.java:76)
:
这是它的Java代码:
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
tabSelected(tab.getPosition()); // Line76
}
编辑:这是崩溃的代码:
final Context context = AppController.getInstance().getContextForActivityActivity();
if (context != null) {
progressIndicator = new ProgressDialog(context);
progressIndicator.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
ProgressBar v = (ProgressBar) progressIndicator.findViewById(android.R.id.progress);
v.getIndeterminateDrawable().setColorFilter(
context.getResources().getColor(R.color.actionColor),
android.graphics.PorterDuff.Mode.MULTIPLY);
}
});
progressIndicator.setTitle(message);
progressIndicator.show();
}
}
这个错误是什么意思?