Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Android: Detecting if a mobile or tablet — Gideros Forum

Android: Detecting if a mobile or tablet

moopfmoopf Guru
edited October 2012 in General questions
Not an easy thing, I know, but I wondered if anybody has previously done this and found a way to be fairly accurate? I'm guessing not automatically as the information returned for application:getDeviceInfo() for Android only returns the version currently according to the Gideros docs.

There is other information, which was improved with 3.0, that it would be useful to also expose using getDeviceInfo() for Android that would make the job easier:

http://developer.android.com/guide/practices/screens_support.html

And details of the constants here:

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

It's obviously easy on iOS to do this and, unless this information can be exposed so we can do our own logic, I'm thinking that the only other option would be to have a setting on the Android distribution of the app that allowed the user to turn on 'tablet mode' in the app and change displays accordingly.

Thoughts appreciated.

Comments

  • Anybody got any thoughts on this? An example of why, even in a game, a layout might be different on a mobile or tablet is that of popup windows (e.g. settings screens). On a mobile you want the popup as large as possible to give clarity (so probably full width of the screen for instance). On a tablet this looks ridiculous and over-sized, so you display a more appropriately sized popup there.

    I did this kind of thing (and different sized buttons on mobile/tablet) in my last game in the app store. A good example of a very popular game that does this is Plants vs. Zombies - they tailor buttons and menus (at least on iOS, not sure about Android) to either mobile or tablet to avoid the game having "gigantism" on tablets.
  • atilimatilim Maintainer
    edited October 2012
    A function to get the screen density (e.g. Application:getScreenDensity) in DPIs can be a solution.

    Afaik, iOS doesn't provide a way to get the screen density but we can use a table similar to http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density#Apple For Android, I'll try to find if it's possible to get screen density at runtime (for Android 2.2+)
  • Yes, fortunately on iOS we're dealing with a known, limited number of devices and you can infer which one pretty easily with the existing information that's available in Gideros.

    Screen density, in conjunction with device width and height, should give enough to make a pretty accurate decision on whether it's a mobiel or tablet.
  • atilimatilim Maintainer
    edited October 2012 Accepted Answer
    Also if you know the screen density, for example you can create a button with radius of exactly 2 inches.

    Nowadays I'm trying to release a new version. If it's possible to get screen density on Android 2.2+, I'll add this function to that release.

    Likes: moopf

    +1 -1 (+1 / -0 )Share on Facebook
  • Oh yes, that's a nice point. That could certainly be useful for some applications.
  • atilimatilim Maintainer
    edited October 2012
    As a side note: On Android, it seems it's only possible to get an approximate value of screen density as low (120), medium (160), high (240), xhigh (320) or xxhigh (480). But I think this also will be enough.
  • Yes that should be fine. As I said, in conjunction with the device width and height, we can then calculate whether we think it's a mobile or tablet with a pretty good degree of certainty.
Sign In or Register to comment.