Skip to content

Instantly share code, notes, and snippets.

@vekexasia
Created August 24, 2012 09:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vekexasia/89fdfb19a7dfd79e3770 to your computer and use it in GitHub Desktop.
Save vekexasia/89fdfb19a7dfd79e3770 to your computer and use it in GitHub Desktop.
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