Bobbake4
Bobbake4

Reputation: 24857

Android is there a way to check for a specific device?

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

Upvotes: 3

Views: 934

Answers (2)

Wroclai
Wroclai

Reputation: 26925

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.

Upvotes: 3

RedLeader
RedLeader

Reputation: 657

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();

Upvotes: 2

Related Questions