Ab.com recognizing tablet/phone/gtv
public static Class getMapActivityClass(Context context) { | |
if (UIUtils.isHoneycombTablet(context)) { | |
return MapMultiPaneActivity.class; | |
} | |
return MapActivity.class; | |
} | |
/* Somewhere else - inside your activity that needs to launch the mapactivity */ | |
public void startMapActivity() { | |
Intent toStart = new Intent(getApplicationContext(), getMapActivityClass(getApplicationContext())); | |
/* Do some other stuff - add extras,flags whatever */ | |
startActivity(toStart); | |
} |
public static boolean isGoogleTV(Context context) { | |
return context.getPackageManager().hasSystemFeature("com.google.android.tv"); | |
} | |
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 hasHoneycomb() && isTablet(context); | |
} | |
public static boolean hasHoneycomb() { | |
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment