I want to pass my ConnectivityManger to my Worker class.
I saw this thread but serialize it to json is not an option for me.
Is there any other way?
My app is designed to use newest api.
CodePudding user response:
You shouldn't pass your ConnectivityManager to your Worker class via input data for a number of reasons:
WorkManager automatically handles connectivity changes when you using
NetworkTypeas part of your work constraintsWorkManager allows injecting dependencies into your Workers via Hilt
If you are referring to Android's
ConnectivityManager(and not your own class you've created), then each Worker can already gain access to aContextand, with that, any system service, such as aConnectivityManager.
