代码其实很简单,用到了方向的传感器所以要用 SensorManger,具体的实现方式:
public class MyOrientationListener implements SensorEventListener { private SensorManager mSensorManager; private Context mContext; private Sensor mSensor; private float lastX; private OnOrientationListener mOnOrientationListener; public void setmOnOrientationListener(OnOrientationListener mOnOrientationListener) { this.mOnOrientationListener = mOnOrientationListener; } public MyOrientationListener(Context context) { this.mContext = context; } public void star() { mSensorManager = (SensorManager) mContext