سؤال

I am new to Android. I want to detect, through code, whether my android device has QWERTY keypad and camera or not. Any suggestions?

هل كانت مفيدة؟

المحلول

For check keypad existence

Fetch the Configuration object using

Configuration config = getResources().getConfiguration();

...and then look at the keyboard field.

If they value of keyboard is not KEYBOARD_NOKEYS, the user has a hardware keyboard.

And for hardware Camera...

PackageManager pm = context.getPackageManager();

if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top