Service not being created (or connecting) after bindService()

后端 未结 3 809
南笙
南笙 2021-02-08 11:55

I have this simple service that broadcasts the current location of the user. I want to use the binding mechanism just to control the service life-cycle, but the service is just

3条回答
  •  甜味超标
    2021-02-08 12:14

    When you call bindService you may get this error:

    ActivityManager java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.android.server.am.ActivityRecord$Token

    Check the output of logcat.

    This is a bug of Android.

    To solve it, use getApplicationContext().bindService(...)

提交回复
热议问题