2016-10-02 128 views
0

在我的項目中,我需要使用IContentService,並且我使用了正確的導入(導入android.content.IContentService),但android studio告訴我'無法解析符號IContentService'。Android - IContentService無法解析

我知道IContentService是一個實際的類,因爲它在ContentResolver.getContentService()中使用;

任何人都知道我可以如何讓這個導入工作?

+0

「android studio告訴我'無法解析符號IContentService'」 - 這是因爲Android SDK中沒有'IContentService'。 「我需要使用IContentService」 - 爲什麼?它是Android內部實現的一部分。不保證在所有版本的Android中都存在,未經修改,可能會由設備製造商或定製ROM開發人員進行修改。 – CommonsWare

+0

你使用哪個API級別,你可以調用'ContentResolver.getContentService()'? – gus27

回答

1

你不能直接使用這個類。

您可以在源代碼中看到(例如here for Marshmallow)該類標有@hide註釋。

該類只能通過反射使用,如here(具有所有缺點)。

順便說一句:ContentResolver.getContentService()也是一種隱藏的方法(見here)。

+0

啊,好的,謝謝! – Userrrrrrrrr