android – what is a non-SDK interface-ThrowExceptions

Exception or error:

After searching new Android P features, I came across the non-SDK interfaces restriction. and my question is,

What is a non-SDK interface or an SDK interface?
What is the difference between them? specially that makes non-SDK once better.
Examples of popular SDK and non-SDK interfaces available for android.

P.S. I came across abstract answers differentiating between SDK and API interfaces but it didn’t fulfill my questions :/

How to solve:

Quoting the documentation:

Generally speaking, SDK interfaces are those ones found documented in the Android framework Package Index.

Not everything in the framework appears in the documentation. Classes, methods, fields, and such marked with @hide in the source code are available at runtime but are not part of the SDK and do not appear in the documentation. These items can only be accessed by unconventional means, such as reflection.

That is what Android P is starting to ban.

For years, I have been advising developers not to access such things, because they are unreliable. Any Android device may not have the hidden stuff, due to changes based on the Android version or device manufacturer/ROM modder tweaks. Now, Google is going to enforce this advice more firmly, at least in some cases.

specially that makes non-SDK once better

They are not “better”. However, they may offer access to certain features that are not available in the SDK, for one reason or another (e.g., API is not settled yet).

Leave a Reply

Your email address will not be published. Required fields are marked *