Android examples for Hardware:Sensor
has Step Sensor
//package com.java2s; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Build; public class Main { public static boolean hasStepSensor(Context context) { if (context == null) { return false; }/*from w w w . jav a 2s . co m*/ Context appContext = context.getApplicationContext(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return false; } else { boolean hasSensor = false; Sensor sensor = null; try { hasSensor = appContext.getPackageManager() .hasSystemFeature( "android.hardware.sensor.stepcounter"); SensorManager sm = (SensorManager) appContext .getSystemService(Context.SENSOR_SERVICE); sensor = sm.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); } catch (Exception e) { e.printStackTrace(); } return hasSensor && sensor != null; } } }