In some of our Activities, we've overridden getSystemService()
method to return some custom objects for custom service names. It works well for us, to pass down some object to a View somewhere deep inside such Activity.
But in Android Studio we get an error generated by a lint inspection in a line that gets our custom system service:
return (CustomService) context.getSystemService(SERVICE_NAME);
I know lint uses a @ServiceName
annotation on getSystemService()
which is defined via a @StringDef
in Context
class. I would like to know how I can extend this definition to include our custom service names.
I wouldn't like to turn of this very usefull inspection nor suppress this error every time we use our custom system service. That's why I hope it is possible to add custom names for lint to recognize that this call is correct.