which is the preferred approach?
IMHO, use Build
.
Which one is faster on the long run?
Build
.
More importantly, Build
tells you what is supported, because you are reading the JavaDocs and making the determination of whether to do something based upon that documentation.
There are many public methods on public Java classes, where the classes are in the Android SDK, but the methods are not. Those get marked with @hide
in the AOSP source code and are stripped out when creating the android.jar
that we link to, when creating the JavaDocs, etc. Those represent methods that are "not ready for prime time" in the eyes of the Android team, but need to be public for internal use within the framework. The reflection technique will happily report that such hidden methods are available for use, even though:
Their method signatures may differ (parameters, return type, exceptions) from what eventually was released in the SDK, either due to Android team changes or manufacturer changes
The behavior of those hidden methods is undocumented and therefore may not match the functionality documented when those methods were released
I'm a big @Macarse fan, but this is one case where we'll have to agree to disagree.