Android Utililty Methods Device Type Check

List of utility methods to do Device Type Check

Description

The list of methods to do Device Type Check are organized into topic(s).

Method

StringgetPhoneModel()
get Phone Model
return android.os.Build.MODEL;
booleanisGoogleTV(final Context context)
Used to determine if the current device is a Google TV
return context.getPackageManager().hasSystemFeature(
        "com.google.android.tv");
booleanisTablet(Context context)
is Tablet
Configuration configuration = context.getResources()
        .getConfiguration();
return (configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
booleanisTablet(Context ctx)
Method that returns if the device is a tablet
Configuration configuration = ctx.getResources().getConfiguration();
return (configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
booleanisTablet(final Context context)
Used to determine if the device is a tablet or not
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
StringgetDeviceName()
get Device Name
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.startsWith(manufacturer)) {
    return capitalize(model);
} else {
    return capitalize(manufacturer) + " " + model;
StringgetPhoneModel()
get Phone Model
return android.os.Build.MODEL == null ? "Unknown"
        : android.os.Build.MODEL;
StringconvertPhoneType(int type)
convert Phone Type
switch (type) {
case TelephonyManager.PHONE_TYPE_NONE:
    return "NONE";
case TelephonyManager.PHONE_TYPE_GSM:
    return "GSM";
case TelephonyManager.PHONE_TYPE_CDMA:
    return "CDMA";
case TelephonyManager.PHONE_TYPE_SIP:
...
StringgetDeviceType(Activity act)
get Device Type
return getDeviceType(act.getApplicationContext());