Starting a service on demand

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

<service android:name="" />

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

<service android:name="" android:enabled="false" />

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

Application.Context.PackageManager.SetComponentEnabledSetting(new ComponentName(Application.Context, ""), ComponentEnabledState.Enabled, ComponentEnableOption.None);
Type serviceType = Type.GetType("");
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 ?



Best Answer


Sign In or Register to comment.