Android examples for Hardware:Sensor
check Sensor Accelerometer
/*//from ww w . j a va 2 s . c om * Copyright(c) 2013- AndroboGroup, All rights reserved. */ import java.util.List; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Build; public class Main{ static final String TAG = "CheckUtil"; public static boolean checkSensorAccelerometer(Context context) { LogUtil.d(TAG, "[IN ] checkSensorAccelerometer()"); boolean result; SensorManager sensorManager = (SensorManager) context .getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensors = sensorManager .getSensorList(Sensor.TYPE_ACCELEROMETER); if (0 < sensors.size()) { result = true; } else { result = false; } LogUtil.d(TAG, "result:" + result); LogUtil.d(TAG, "[OUT] checkSensorAccelerometer()"); return result; } }