[英]Android : How to detect the device is Huawei or not?
I am trying to find a way to detect whether the device is Huawei or not.我正在尝试找到一种方法来检测该设备是否为华为。 My app has a piece of code that causes a crash on Huawei devices, I want to avoid executing that code if the device is Huawei.
我的应用程序有一段代码会导致华为设备崩溃,如果设备是华为,我想避免执行该代码。
I don't want to use checks based on GMS & HMS availability cause my app does not contain dependency for these packages.我不想使用基于 GMS 和 HMS 可用性的检查,因为我的应用不包含对这些包的依赖项。
Thanks谢谢
Try this.尝试这个。 The Code standard is poor, but it gets the job done.
代码标准很差,但它完成了工作。 I don't think Huawei will ever change its name.
我认为华为永远不会更改其名称。
private boolean isHuaweiDevice(){
String manufacturer = android.os.Build.MANUFACTURER;
String brand = android.os.Build.BRAND;
return manufacturer.toLowerCase().contains("huawei") || brand.toLowerCase().contains("huawei");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.