Search code examples
androidscreenandroid-3.0-honeycombandroid-4.0-ice-cream-sandwich

Android Honeycomb application running on ICS (Ice Cream Sandwitch)


I have an application developed for Honeycomb (initially 3.0) and after the ICS is released the users can install it to theirs phones with ICS, not just to tablets. How can I filter these phones? I have tried with the <support-screens> but that is not working. Also an interesting (at least to me) thing my application won't scale down to smaller screens. I used fixed sized controls but the size is in dp.

In short:

  1. Somebody knows how can I filter the ICS phones? (preferably from code)
  2. What should I do to support ICS phones? (I guess I need to implement a whole new layout for the ICS phones, but it is still a question to me how can I determine what kind of device is it, phone or tablet?

Solution

  • public static boolean isHoneycomb() {
        // Can use static final constants like HONEYCOMB, declared in later versions
        // of the OS since they are inlined at compile time. This is guaranteed behavior.
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
    }
    
    public static boolean isTablet(Context context) {
        return (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK)
                >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    }
    
    public static boolean isHoneycombTablet(Context context) {
        return isHoneycomb() && isTablet(context);
    }
    

    Copied from this answer here: https://stackoverflow.com/a/8427523/253583

    You will also probably want to restrict Android Market from enabling users to install this on phones with http://developer.android.com/guide/topics/manifest/supports-screens-element.html in your manifest.