Can I detect an Amazon tablet and others?

I use the Google service in my project, but the Amazon tablets do not support the Google service, so if I want to publish the application on the Amazon Store, I need to remove the Google service. I don’t want to divide the project into "For Google Play" and "For Amazon Store".
I get the device name using android.os.Build.MODEL, but I'm not sure if it is safe?
Can I detect Amazon tablets in a project?

if(is Amazon) {
    //do something
}
else {
    //do something
}
+4
source share
3 answers

Yes, you can use Build.MODEL and Build.MANUFACTURER.

Amazon, Build.MANUFACTURER "Amazon", Build.MODEL , .

Amazon, :

if (Build.MANUFACTURER.equals("Amazon")) {
    //we have an Amazon tablet
}
else {
    //some other device
}

, , Build.MODEL, :

  • Kindle Fire HDX 8.9 (3rd Gen)

    if (Build.MODEL.equals("KFAPWI")) {
        //WiFi version
    }
    else if (Build.MODEL.equals("KFAPWA")) {
        //WAN version
    }
    

    .

+7

..

String deviceName = android.os.Build.MODEL;
String deviceMan = android.os.Build.MANUFACTURER;

. android.os.Build

+2

, Google Play . Google Play. :

private static final String GooglePlayStorePackageNameOld = "com.google.market";
private static final String GooglePlayStorePackageNameNew = "com.google.vending";

public boolean serviceAvailable(Context ctx) {
    boolean googlePlayStoreInstalled= false;
    packageManager = ctx.getPackageManager();
    List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
    for (PackageInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(GooglePlayStorePackageNameOld) ||
            packageInfo.packageName.equals(GooglePlayStorePackageNameNew)) {
            googlePlayStoreInstalled = true;
            break;
        }
    }
    return googlePlayStoreInstalled;
}
0

All Articles