0

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?

Userrrrrrrrr
  • 183
  • 3
  • 12
  • "android studio tells me 'Cannot resolve symbol IContentService'" -- that is because there is no `IContentService` in the Android SDK. "I need to use IContentService" -- why? It is part of the internal implementation of Android. It is not guaranteed to exist, unmodified, in all versions of Android and may be modified by device manufacturers or custom ROM developers. – CommonsWare Oct 02 '16 at 13:21
  • Which API level are you using that you can call `ContentResolver.getContentService()`? – gus27 Oct 02 '16 at 13:40

1 Answers1

1

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).

Community
  • 1
  • 1
gus27
  • 2,616
  • 1
  • 21
  • 25