3

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.

Thanks

Dhanaji Yadav
  • 1,202
  • 1
  • 14
  • 22

1 Answers1

4

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");
}
Dhanaji Yadav
  • 1,202
  • 1
  • 14
  • 22