开发者

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 i开发者_运维问答f it is.

Thanks


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜