How to determine if the client is a touch device [duplicate]

You can use the following JS function: function isTouchDevice() { var el = document.createElement(‘div’); el.setAttribute(‘ongesturestart’, ‘return;’); // or try “ontouchstart” return typeof el.ongesturestart === “function”; } Source: Detecting touch-based browsing. Please note the above code only tests if the browser has support for touch, not the device. Related links: How to detect a mobile device … Read more

Emulate Samsung Galaxy Tab

UPDATED: Matt provided a great link on how to add emulators for all Samsung devices. OLD: To get the official Samsung Galaxy Tab emulator do the following: Open the Android SDK and AVD Manager Click on Available packages Expand the Third party Add-ons. There you will see Samsung Electronics add-ons. Once the add-on is installed … Read more

Layout for tablets in Android

I know this is an old question, but for the sake of it… According documentation, you should create mutiple asset folders like this res/layout/main_activity.xml # For handsets (smaller than 600dp available width) res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger) res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)

JavaScript how to check User Agent for Mobile/Tablet

First – improving the condition if (navigator.userAgent.match(/iPad/i)) { // do tablet stuff } else if(navigator.userAgent.match(/Android|webOS|iPhone|iPod|Blackberry/i) ) { // do mobile stuff } else { // do desktop stuff } Second, adding the missing keywords: if (navigator.userAgent.match(/Tablet|iPad/i)) { // do tablet stuff } else if(navigator.userAgent.match(/Mobile|Windows Phone|Lumia|Android|webOS|iPhone|iPod|Blackberry|PlayBook|BB10|Opera Mini|\bCrMo\/|Opera Mobi/i) ) { // do mobile stuff } else … Read more

Why my App is not showing up on tablets in Google Play?

At last adding a special case for Nexus 7 with in <compatible-screens> tag worked for me. As Nexus 7 has tvdpi density <compatible-screens> <!–no small size screens –> <!–all normal size screens –> <screen android:screenSize=”normal” android:screenDensity=”ldpi” /> <screen android:screenSize=”normal” android:screenDensity=”mdpi” /> <screen android:screenSize=”normal” android:screenDensity=”hdpi” /> <screen android:screenSize=”normal” android:screenDensity=”xhdpi” /> <!– all large size screens –> … Read more

Navigation Drawer: set as always opened on tablets

Based on the idea of larger devices could have different layout files, I have created the follow project. https://github.com/jiahaoliuliu/ABSherlockSlides HighLights: Since the drawer of a large device is always visible, there is not need to have an drawer. Instead, a LinearLayout with two elements with the same name will be enough. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” … Read more

Android: allow portrait and landscape for tablets, but force portrait on phone?

Here’s a good way using resources and size qualifiers. Put this bool resource in res/values as bools.xml or whatever (file names don’t matter here): <?xml version=”1.0″ encoding=”utf-8″?> <resources> <bool name=”portrait_only”>true</bool> </resources> Put this one in res/values-sw600dp and res/values-xlarge: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <bool name=”portrait_only”>false</bool> </resources> See this supplemental answer for help adding these directories and … Read more

Tablet or Phone – Android

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 … Read more