As it has been mentioned before, you do not want to check whether the device is a tablet or a phone but you want to know about the features of the device,
Most of the time, the difference between a tablet and a phone is the screen size which is why you want to use different layout files. These files are stored in the res/layout-<qualifiers> directories. You can create an XML file in the directoy res/values-<same qualifiers> for each of your layouts and put an int/bool/string resource into it to distinguish between the layouts you use.
Example:
File res/values/screen.xml (assuming res/layout/ contains your layout files for handsets)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="screen_type">phone</string>
</resources>
File res/values-sw600dp/screen.xml (assuming res/layout-sw600dp/ contains your layout files for small tablets like the Nexus 7)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="screen_type">7-inch-tablet</string>
</resources>
File res/values-sw720dp/screen.xml (assuming res/layout-sw720dp/ contains your layout files for large tablets like the Nexus 10):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="screen_type">10-inch-tablet</string>
</resources>Now the screen type is accessible via the R.string.screen_type constant.
http://stackoverflow.com/questions/5832368/tablet-or-phone-android
'옛날' 카테고리의 다른 글
| 공유 Intent [Android] (0) | 2015.12.14 |
|---|---|
| Webview source [Android] (0) | 2015.12.14 |
| 튜토리얼 페이지 [Android] (0) | 2015.12.11 |
| Coach mark View [Android] (0) | 2015.12.11 |
| Webview 소스 [Android] (0) | 2015.12.11 |