Userrrrrrrrr Userrrrrrrrr - 2 months ago 6
Android Question

Android - IContentService cannot be resolved

In my project I need to use IContentService, and I've used the right import (import android.content.IContentService) and yet android studio tells me 'Cannot resolve symbol IContentService'.

I know IContentService is an actual class, because it is used in ContentResolver.getContentService();

Anyone know how I can get this import to work?

Answer

You cannot use this class directly.

You can see in the source code (e.g. here for Marshmallow) that this class is tagged with the @hide annotation.

The class can only be used by reflection as shown here (with all it's disadvantages).

BTW: ContentResolver.getContentService() is also a hidden method (see here).

Comments