Starting a service on demand

I have a service that works fine if i let it start in the AndroidManifest like

<service android:name="com.company.BackgroundUploader" />

I would like to start this service only when it is needed so added a enabled="false" to a service:

<service android:name="com.company.BackgroundUploader" android:enabled="false" />

i then programmatically re-enable it and try to start it

Application.Context.PackageManager.SetComponentEnabledSetting(new ComponentName(Application.Context, "com.company.BackgroundUploader"), ComponentEnabledState.Enabled, ComponentEnableOption.None);
Type serviceType = Type.GetType("com.company.BackgroundUploader");
Application.Context.StartService(new Intent(Application.Context, serviceType));

however the StartService call throws an exception

type Parameter name: Type is not derived from a java type.

with not much more information .
can anyone see what i am missing here ?

thanks

Tagged:

Best Answer

Answers

Sign In or Register to comment.