Standard way of checking camera and telephony hardware availability works only since SDK >= 5:
PackageManager pm = this.getPackageManager();
boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
boolean hasCamera=pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
My problem that I need to runtime define availability of telephony and camera in SDK 3 (Android 1.5)
Any ideas?
P.S. I understand that Android 1.5 is very outdated, but still I do have bunch of customers running these devices, so I have to keep compatibility with them.
Well, I have found solution - very odd but it's working.
Basically method tries to get telephony service if it's null - it returns false, if it's not null (e.g. for HTC Flyer
TelephonyManager
is not null) method tries to runPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
using reflection, since this method is not available for old versions of SDK.Here is a code:
More or less the same approach is workable for checking of camera availability