Java tutorial
//package com.java2s; import android.content.Context; import android.hardware.SensorManager; public class Main { /** * To determine whether it contains a gyroscope * * @return */ public static boolean isHaveGravity(Context context) { SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); if (manager == null) { return false; } return true; } }