How to instantiate android service with a constructor?

后端 未结 6 1947
北海茫月
北海茫月 2021-01-04 09:21

I have a service with an following constructor:

public ShimmerService(Context context, Handler handler) {
    mHandler = handler;
}

I want

6条回答
  •  北海茫月
    2021-01-04 09:28

    Dont pass the Handler to the Service, Handler doesnt implement Parcelable, or Serializable, so I dont think thats possible.

    Create the Handler in the Service, and pass any data you need to create the Handler via Intent Extras to the Service.

提交回复
热议问题