Skip to content

Instantly share code, notes, and snippets.

@yrom
Created May 21, 2014 09:19
Show Gist options
  • Save yrom/9918a8d5244a2f8ced11 to your computer and use it in GitHub Desktop.
Save yrom/9918a8d5244a2f8ced11 to your computer and use it in GitHub Desktop.
Android: Check for Available Features at Runtime
// Check if android.hardware.telephony feature is available.
if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {
Log.d("Mobile Test", "Running on phone");
// Check if android.hardware.touchscreen feature is available.
} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
Log.d("Tablet Test", "Running on devices that don't support telphony but have a touchscreen.");
} else {
Log.d("TV Test", "Running on a TV!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment