Is it possible to perform a runtime check to see if a device is running Android-Things?
You can query the PackageManager
for FEATURE_EMBEDDED
, which is implemented by all Android Things devices:
public boolean isThingsDevice(Context context) {
final PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
This constant was recently added in the Android O Preview SDK. Until an Android Things preview based on O is released, you may need to use the literal name of the constant: android.hardware.type.embedded
Any apk you make with AndroidThings will be uploaded to the IoT console not to the play store.
Therefore I would recommend if you want a single codebase that you use Gradle Flavors and a flag. This means you will build two separate APK's - rather than doing a "what platform am I on" check at runtime.
This will ensure your APK has the smallest size on both memory constrained separate platforms. (For instance the flavor of Google Play Services that is used on Android Things is a slimmed down version of what is available for general Android apps). Android Things supports a subset of the Google APIs for Android. The linked table breaks down API support in Android Things.
© 2022 - 2024 — McMap. All rights reserved.
Class.forName()
to see if they exist. – Bipod