3

I am writing an app that the layout is a little off on the Droid X2. Is there a way to detect in code if the device is a Droid X2? I would like to add a small amount amount of padding to the layout if it is.

Thanks

1
  • 1
    Shouldn't you rather figure out what exactly is causing things to be off and then detect that instead of detecting the specific device? Commented Jul 13, 2011 at 22:00

2 Answers 2

3

Use Build.PRODUCT.

Sample code:

if (Build.PRODUCT.contains("droid x2")) { // Add stuff. } 

Another important point to add. If this doesn't work, make sure to debug what the Build.PRODUCT contains in order to see if that is the correct info. Otherwise, you can check what Build.MODEL returns and go with that.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't think that is a reliable way to tell. Some users uses custom ROMs that may have different values.
Correct. Users with custom ROM:s can customize stuff, so I will, in this case, just think of users with standard values.
2

Would this help? You could have a variable change based on the screen size instead of manually changing for devices:

getWindow().getWindowManager().getDefaultDisplay().getWidth(); getWindow().getWindowManager().getDefaultDisplay().getHeight(); 

2 Comments

Well it isn't a screen size issue. All the HDPI devices look perfect except for the Droid X2.
Okay. Well I guess this would help: android.os.Build.DEVICE; returns a string.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.