Identifying Fire TV Devices
Most Amazon Fire TV developers build apps for both Google Play and the Amazon Appstore, using the same Android-based code for both app markets and devices. Because Amazon devices don't use Google services (they use Amazon services and APIs instead), you might need to target your code in different ways. Additionally, within Fire OS, there are several versions:
- Fire OS 5: Based on Android 5.1 (Lollipop, API level 22)
- Fire OS 6: Based on Android 7.1 (Nougat, API level 25)
- Fire OS 7: Based on Android 9 (Pie, API level 28)
- Fire OS 8: Based on Android 10 (API Level 29) and Android 11 (API level 30)
This documentation provides details on identifying Amazon devices based on features, models, and API levels. You can find details about which Fire TV device has which Fire OS version in the Fire TV Device Specifications.
- Reasons for Checking the Amazon Fire TV Device
- Identify Amazon Devices by Feature and Model
- Check for the API Level
- Check Whether 4K Is Supported
- adb Commands to Check for Properties or Features
Reasons for Checking the Amazon Fire TV Device
You might want to check for the Amazon Fire TV device in your code for a number of reasons:
- You have Android 10 (API level 29) or Android 11 (API level 30) features that are supported only on Fire OS 8 devices.
- You have Pie-specific (API level 27 and up) features that are supported only on Fire OS 7 devices.
- You have Nougat-specific (API level 25 and up) features that are supported only on Fire OS 6 devices.
- You want to determine whether the app needs to tear down the DRM and HW decoding pipeline in their
onPause()
method (which is needed for Fire TV -1st Gendue to limited handling of multiple DRM contexts).
Identify Amazon Devices by Feature and Model
You can identify Amazon Fire TV devices by looking for amazon.hardware.fire_tv
as a feature. You can also use patterns in the android.os.Build.MODEL
. See the Fire TV Device Specifications for information about each device's build model. The following image shows the build model for each device. (You can see this dialog when you upload your APK into the Dev Console.)
All Fire TV devices can be identified through the feature amazon.hardware.fire_tv
. You get the feature by calling the getPackageManager()
method on the Context
object and checking whether hasSystemFeature()
returns com.hardware.amazon.fire_tv
. The following code shows a sample:
final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
if (getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV)) {
Log.v(TAG, "Yes, this is a Fire TV device.");
} else {
Log.v(TAG, "No, this is not a Fire TV device.");
}
You can also identify Fire TV devices by combining the android.os.Build.MODEL
with the Build.MANUFACTURER
(which returns Amazon
).
However, as more Amazon-powered devices come to market with non-Amazon manufacturers, combining the android.os.Build.MODEL
with the Build.MANUFACTURER
may not always work. Because of this, include a sensible fallback approach for future Amazon Fire TV devices based on the com.hardware.amazon.fire_tv
feature. Here's a code sample that looks for the model but falls back on the feature:
final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
String AMAZON_MODEL = Build.MODEL;
if (AMAZON_MODEL.matches("AFTN")) {
Log.v(TAG, "Yes, this is a Fire TV 3rd Gen device");
} else if (getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV)) {
Log.v(TAG, "Yes, this is a Fire TV device.");
} else {
Log.v(TAG, "No, this is not a Fire TV device");
}
Check for the API Level
To implement conditional behavior based on Android API level, you can check for the API level of the device using SDK_INT. For example, the following code checks whether the version is greater than or equal to API level 25:
if (Build.VERSION.SDK_INT >= 25) {
Log.v(TAG, "Yes, this is an API level 25 or higher device");
} else {
Log.v(TAG, "No, this is not an API level 25 or higher device");
}
In this case, the code would target Fire OS 6 and higher (API level 25+) and exclude any Fire OS 5 devices (API level 22). If you want to target only Fire OS 5 devices, you would use a similar logic:
if (Build.VERSION.SDK_INT <= 22) {
Log.v(TAG, "Yes, this is an API level 22 or lower device");
} else {
Log.v(TAG, "No, this is not an API level 22 or lower device");
}
Check Whether 4K Is Supported
To check whether 4K is supported, use the standard Android Display.Mode APIs, which were introduced in Android 6.0. Display.Mode
allows applications to query physical display sizes and switch to a different HDMI display mode.
For Fire OS 5 devices (which are based on Android 5.1, before Display.Mode
was released), Display.Mode
is also available (due to some backporting of these APIs into Fire OS) but reflection must be used. Amazon provides a 4K Extension Library that wraps these Android APIs via reflection and provides a simple interface for them. See APIs for HDMI Mode Switch for more details.
adb Commands to Check for Properties or Features
If you want to see which properties or features a device has using adb, you can do the following:
- Connect to ADB.
- To see the device's properties, run
adb shell getprop
. - To see the device's features, run
adb shell pm list features
.
Last updated: Feb 09, 2024