Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android-What does Build.MANUFACTURER return on htc devices

Tags:

android

build

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?

like image 315
James andresakis Avatar asked Nov 26 '11 01:11

James andresakis


1 Answers

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.

like image 94
Jack Avatar answered Sep 30 '22 04:09

Jack