Java tutorial
//package com.java2s; import android.content.Context; import android.hardware.SensorManager; public class Main { public static boolean isSensorAvailable(Context ctx, int type_sensor) { boolean isSensorAvailable = false; SensorManager sensorManger = null; sensorManger = (SensorManager) ctx.getSystemService(ctx.SENSOR_SERVICE); if (sensorManger.getDefaultSensor(type_sensor) != null) { isSensorAvailable = true; } return isSensorAvailable; } }