[FIXED] Dependency injection with JobService subclass in MAUI application

Issue

[for Android platform]

Is there any way to inject dependencies into JobService subclass?
In order to compile JobService subclass must not contain constructor with parameters and from the documentation you can only use SetExtras to send some simple data to it.

So what should I do in order to use a service that is in a DI container, resolve it using IServiceProvider or something else?

Solution

As per discussion I found on reddit it constructor injection is a common issue with Android activities/services etc. but there seems to be a workaround by using dependency resolver the way James Montemagno describes it here.

Answered By – 0wl

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published