I have metadata in the AndroidManifest.xml for my service. Getting this metadata is fairly straightforward in an activity, as all you have to do is something like this:
final Bundle data =
getPackageManager().getActivityInfo(this.getComponentName(), PackageManager.GET_META_DATA).metaData;
For services, I would obviously be using the ‘getServiceInfo()’ method instead of the activity info, but there is no ‘getComponentName()’ method in a Service. Is there any reason why this isn’t available? Do I have to construct my own ComponentName object here?
Thanks
AFAIK, yes. From a
Service,new ComponentName(this, this.getClass())should give you aComponentNamefor the service itself.