Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How check if a specific sensor exists on a device?

I'm developing an android app that uses Sensors and I would like to know the best way to detect if a device has a specific sensor, let's say, a Proximity Sensor.

Also, is there any "filter" that can be applied to the manifest so users who don't have a proximity sensor won't be able to install the app? If exists, will this "filter" also be valid on Google Play, so users won't be able to see the app?

like image 491
Pedro Lobito Avatar asked Dec 01 '22 00:12

Pedro Lobito


1 Answers

This is most likely what you are looking for in checking the features programtically

PackageManager PM= this.getPackageManager();
boolean gps = PM.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
boolean acc = PM.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);

This link explains what you can do to filter your application in the marketplace, look specifically at the section

Market Filters

like image 194
Idistic Avatar answered Dec 05 '22 09:12

Idistic