Java tutorial
//package com.java2s; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorManager; import java.util.List; public class Main { public static boolean checkSensor(int sensor, Context context) { SensorManager sensorManger = (SensorManager) context.getApplicationContext() .getSystemService(Context.SENSOR_SERVICE); List<Sensor> lista = sensorManger.getSensorList(sensor); return lista.size() > 0; } }