开发者

Is there any way for an android app to know which device its installed on?

开发者 https://www.devze.com 2023-02-07 06:49 出处:网络
Suppose I wanted to target a specific few 开发者_开发知识库Android devices (e.g. tablet), is there any means for an app to know which device its installed in? I mean I would like the app to know what

Suppose I wanted to target a specific few 开发者_开发知识库Android devices (e.g. tablet), is there any means for an app to know which device its installed in? I mean I would like the app to know what kinds of features the device has, for example, front facing camera, screen resolution, etc. It would be best to be able to know the exact device the app is working in as it would help make the app actually usuable ;).

If that sounds ridiculous, as an Android developer can you specify when you publish your app which device(s) you want the app available in?

I guess ultimately I could write in capitals EXCLUSIVE TO or AVAILABLE IN "insert device name" in the app description.

Thanks in advance.


Try...

String s="Debug-infos:";
s += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
s += "\n OS API Level: " + android.os.Build.VERSION.SDK;
s += "\n Device: " + android.os.Build.DEVICE;
s += "\n Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")";


If you want to design an app for a tablet, you should be looking at the screen size.

You can find out the screen size with Resources.getConfiguration().screenLayout:

http://developer.android.com/reference/android/content/res/Configuration.html#orientation

Note your first decision there is going to be whether you consider a tablet to be the size SCEENLAYOUT_SIZE_XLARGE or both XLARGE and SCREENLAYOUT_SIZE_LARGE. (Note XLARGE is introduced in Honeycomb; you can find the constant in the preview SDK.)

If you want to limit which devices will see your app on Market, you can use the supports-screens tag to specify which screen sizes you are compatible with. For example

<supports-screens android:smallScreens="false" android:normalScreens="false" />

More information on screen sizes is here: http://developer.android.com/guide/practices/screens_support.html

0

精彩评论

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

关注公众号