How can I distinguish phone from tablet - android

Using Adobe AIR for Android, I'd like to find a way to distinguish a phone from a tablet. The closest I can find is detecting the dpi. (My phone dpi is 254, my tablet is 149) but is that going to be reliable or is there a better way?
(I've been using stackoverflow for a while but this is my first post - yippee!!)

but is that going to be reliable
Absolutely not. A T-Mobile G1 would be a tablet by that measure.
is there a better way?
Frankly, you should not be caring whether an Android device is a telephone, tablet, television, toaster, telescope, or toilet.
You should be caring about characteristics and capabilities.
For example, if you are thinking about tablets in terms of screen size, use <supports-screens> and the -large and -xlarge resource sets (e.g., res/layout/ for normal stuff and res/layout-large/ for larger screen sizes).
Or, if you are thinking about tablets in terms of whether or not you can place a phone call, use <uses-feature> and hasSystemFeature() on PackageManager.

Whether a device is a tablet or not could mean...
One.... Is it running the Honeycomb tablet version (Android 3.0) ? You can use System.getProperty() to get this information.
or
Two....Is it tablet sized? i.e. is the screen a larger size? But bear in mind some tablets are not that big. Best way to handle these is separate resources for each device size.
I'd say in general it's a bad idea to try to define Android tablets into specific groups, as there are many varieties now and a LOT more are coming. So usually best to build your app so it handles different screen sizes, different OS versions, and different features being available or absent (e.g. GPS, keyboard etc).

cdotspace, don't worry about the real dpi, you only need to get virutal dpi:
int virtual_dpi=webview1.getResources().getDisplayMetrics().densityDpi;
Virutal dpi means dots per virtual inch.
For example, the htc desire hd's real width is 2.21 inches, but its virutal width is still 2 inches, the galaxy tab 10.1's real width is 5.35 inches(portrait orient), but its virtual width is 5 inches.
int portrait_width_pixel=Math.min(this.getResources().getDisplayMetrics().widthPixels, this.getResources().getDisplayMetrics().heightPixels);
int dots_per_virtual_inch=this.getResources().getDisplayMetrics().densityDpi;
float virutal_width_inch=portrait_width_pixel/dots_per_virtual_inch;
if (virutal_width_inch<=2)
{//is phone
}
else
{//is tablet
}

Related

Detecting 'Phablets' like the Note 3 for layout

I am trying to differentiate layouts in Android (ICS+) for larger devices like the note 3 but finding it next to impossible to do without reading the device name or attempting to calculate physical size in code.
The (deprecated) size attribute for the note 3 identifies as normal, as does the HTC One Mini.
Same goes for using sw350dp / xxhdpi. Not sure if the HTC Mini is the unusual device here, but I would imagine all the newer high-end mini handsets will be the same. I also don't want to use px values if I can help it as smaller devices can (and probably will) go up to 1080p, and notes prior to 3 use lower.
Is there something I am missing here? If not, is any reliable way to calculate the physical size or am I better off hard-coding device lists to provide optimal layouts?
EDIT
So part of this was due to multiple overriding layout folders causing some funkiness and I now have the Mini using the correct values, however I am still in the same situation with the S4 and Note 3 using the same resources. While this is not as bad, it still isn't optimal.
I expect that the Note 1 and 2 will also drop back to the lower DPI resources meaning their real-estate won't be utilised either.
Do NOT use screen size approach. Some phablet users who have Galaxy Mega 5.8/6.3 device or Nexus 6 may have unintended experience.
Use resource based approach sw600dp and sw720dp as below link.
Tablet or Phone - Android

Will samsung GS 4 be a Large or Normal sized device for Android layout purposes?

The upcoming Samsung Galaxy S4.
Reported Specs:
1080 x 1920
4.99 inch diagonal
If I plug that into a new Device definition in AVD, the resulting device size is listed as "Normal" and the Density as "xxhdpi", screen ratio long.
However if I put in a diagonal of 5.00 inches the size changes to "Large".
What to tust?
More generally: Does the AVD device manager match exactly the logic used on Android devices in determining what layout bucket to pull from (unless manufacturer overrides)?
Edit: note regarding the above sentence: When you enter the diagonal and screen dimensions the AVD dropdowns will automatically configure themselves according to those values.
And please oh please don't direct me to the dreaded "Supporting Multiple Screens" page which does not give exact logic.
Will samsung GS 4 be a Large or Normal sized device for Android layout purposes?
You will know when everybody else knows, when the device ships. Samsung can choose whatever it wants for the screen size.
Does the AVD device manager match exactly the logic used on Android devices in determining what layout bucket to pull from (unless manufacturer overrides)?
No, the "AVD device manager" uses whatever screen size bucket you chose when you created the device definition. There is a drop-down listing the various choices.

Android and iOS devices hardware perspective programmming experiences

Having some experiences with iOS. I now look venturing into Android devices. One of obvious differences between iOS devices and Android devices is the Android hardware's specs.
I am interested in to find out your experiences in programming perspective in the two platforms. And only specifically to programmings that will utilize hardware on Android devices such as WiFi, bluetooth, camera, microphone, etc. and to be compatible with different Android devices manufactures.
Android gives you an sdk for working with any hardware module.
Camera, bluetooth, wi-fi, gps.
So the implementation of camera app will be same for any phone.
For exmaple there is a difference where some devices mount sdcard. By default it is /mnt/sdcard. But Samsung uses a different path. But you can use GetExternalStorageDirectory() to return the correct directory regardless of device.
The biggest problem of android is screen sizes. You have a bunch of sizes from 2" to 10-12"(There is bigger and smaller devices..) Also you have a bunch of resolutions and densities.
By the standards it is small, normal, large, xlarge screens with ldpi, mdpi, hdpi densities.
You have to create a layout for each screen size, and all of your pics should be in three sizes(for each density). Also fonts size in sp, and UI elements size in dp. It is density independent measures.
Doesn't sound very hard. But some manufacturers are trying to be on the top - and creating some small size screens with enormous resolution and density. So it will be a big problem to create proper layout.

Minimum android tablet size information needed

I want to develop application with single binary for Android device and for Android tablets with target android 2.1 version.
My orientation also depends upon whether app is running on device or on tablet.
So i just want to know, is there any specification like tablet should be minimum of "X" inches.
There is heaps of information on screen sizes and each device can be different so you should use the Android standards talked about here to figure out exactly what screen you are dealing with and react accordingly. There are no hard and fast "atleast X inches" rules; just different screen sizes of different resolutions. You can use the Android manifest to restrict the screen sizes to just the ones that you want to support.
My orientation also depends upon whether app is running on device or on tablet.
Your application should depend on whether the screen is small, normal, large, or xlarge. There is no concept of "device or on tablet" in Android.
is there any specification like tablet should be minimum of "X" inches.
There is no concept of "tablet" in Android. What a user will think of as a "tablet" will tend to be large or xlarge screen size.

Which layout will use a 10,1" 1024x600 tablet?

I want to make sure that devices with 10,1" and 1024x600 under 2.1/2.2(e.g. Archos 101) are using the correct layout.
Are they large and ldpi?
Also, how can I simulate them using the android emulator?
In the end, the choices of screen size and screen density are up to the manufacturer. Hence, nobody here can answer you definitively.
A 10.1" diagonal screen should be large and probably should be ldpi, though it is possible it will be declared mdpi based upon the apparent density given the distance one would typically hold a 10.1" tablet from one's face.
Bear in mind that ARCHOS' devices do not ship with the Android Market AFAIK, and hence do not necessarily pass the various compatibility tests. As a result, ARCHOS could do all sorts of stuff that would be unexpected.
Also, how can I simulate them using the android emulator?
The Android SDK is not well-suited for testing a 10.1" LCD at this time. I would expect better instructions and support for such sizes in Android 3.0.
For now, set the resolution and density for the AVD when you create it. In this case, you would want to specify 120dpi (ldpi) for the density. Android should put it in the large screen size bucket for you, given those values. Leastways, that basic approach works for getting large WVGA devices.

Categories

Resources