3

When running my Android application on the emulator I get the following error sometimes:

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)

The last line in my code which raises this error is: ServiceSelectionFragment$1.onTabSelected(ServiceSelectionFragment.java:76):

Here is its Java code:

tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
      @Override
      public void onTabSelected(TabLayout.Tab tab) {
        tabSelected(tab.getPosition());  // Line76 
      }

Edit: Here is the code which crashes:

  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();
  }
}

What does this error mean?

emackey
  • 11,818
  • 2
  • 38
  • 58
stephan1002
  • 447
  • 2
  • 5
  • 11

0 Answers0