Obviously I know it will return htc but is it caps or lower case? I recently had a user of one of my apps tell me one of the functions crashed his phone so I want to exclude that function from htc devices for the time being based on what I get from Build.MANUFACTURER and also Build.VERSION.SDK_INT. I just have no idea what will return from Build.MANUFACTURER on an htc device or other devices for that matter. Does anyone know of a list somewhere that would have all that type of info?
Please see this link for a list of manufacturers.
Here is how I detect whether or not a device is manufactured by HTC. Note that I don't care whether or not it matches HTC or htc exactly, I toLower() it and check to see if Build.MANUFACTURER CONTAINS htc at all.
public boolean isAnHTCDevice()
{
String manufacturer = android.os.Build.MANUFACTURER;
if (manufacturer.toLowerCase().contains("htc"))
return true;
else
return false;
}
EDIT (almost two years later) - modified code and added TVK's recommendation:
public boolean isAnHTCDevice()
{
String manufacturer = android.os.Build.MANUFACTURER;
return manufacturer.toLowerCase(Locale.ENGLISH).contains("htc");
}
Shortened return statement, added Local.ENGLISH to .toLowerCase as recommended by Lint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With