List of usage examples for android.hardware Sensor TYPE_ACCELEROMETER
int TYPE_ACCELEROMETER
To view the source code for android.hardware Sensor TYPE_ACCELEROMETER.
Click Source Link
From source file:Main.java
public static String getSenserNameByType(final int type) { switch (type) { case Sensor.TYPE_LINEAR_ACCELERATION: return "Linear Acceleration Senser"; case Sensor.TYPE_GYROSCOPE: return "Gyroscope Senser"; case Sensor.TYPE_ACCELEROMETER: return "Accelerometer Senser"; case Sensor.TYPE_MAGNETIC_FIELD: return "Magnetic Field Senser"; default:/*from ww w.j a va 2 s. c om*/ return "Unknown Senser"; } }
From source file:Main.java
public static boolean isSupportAccelerometerSensor(Context context) { SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); return sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null; }
From source file:Main.java
@SuppressWarnings("deprecation") public static String getSensorTypeStr(int type) { switch (type) { case Sensor.TYPE_ALL://-1 return "TYPE_ALL"; //Accelerometer sensor type case Sensor.TYPE_ACCELEROMETER://1 return "TYPE_ACCELEROMETER"; //Magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD://2 return "TYPE_MAGNETIC_FIELD"; //Orientation sensor type case Sensor.TYPE_ORIENTATION://3 return "TYPE_ORIENTATION"; //Gyroscope sensor type case Sensor.TYPE_GYROSCOPE://4 return "TYPE_GYROSCOPE"; //Light sensor type case Sensor.TYPE_LIGHT://5 return "TYPE_LIGHT"; //Pressure sensor type case Sensor.TYPE_PRESSURE://6 return "TYPE_PRESSURE"; //Temperature sensor type case Sensor.TYPE_TEMPERATURE://7 return "TYPE_TEMPERATURE"; //Proximity sensor type case Sensor.TYPE_PROXIMITY://8 return "TYPE_PROXIMITY"; //Gravity sensor type case Sensor.TYPE_GRAVITY://9 return "TYPE_GRAVITY"; //Linear acceleration sensor type case Sensor.TYPE_LINEAR_ACCELERATION://10 return "TYPE_LINEAR_ACCELERATION"; //Rotation vector sensor type case Sensor.TYPE_ROTATION_VECTOR://11 return "TYPE_ROTATION_VECTOR"; //Relative humidity sensor type case Sensor.TYPE_RELATIVE_HUMIDITY://12 return "TYPE_RELATIVE_HUMIDITY"; //Ambient temperature sensor type case Sensor.TYPE_AMBIENT_TEMPERATURE://13 return "TYPE_AMBIENT_TEMPERATURE"; //Uncalibrated magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED://14 return "TYPE_MAGNETIC_FIELD_UNCALIBRATED"; //Uncalibrated rotation vector sensor type case Sensor.TYPE_GAME_ROTATION_VECTOR://15 return "TYPE_GAME_ROTATION_VECTOR"; //Uncalibreted gyroscope sensor type case Sensor.TYPE_GYROSCOPE_UNCALIBRATED://16 return "TYPE_GYROSCOPE_UNCALIBRATED"; //Significant motion trigger sensor case Sensor.TYPE_SIGNIFICANT_MOTION://17 return "TYPE_SIGNIFICANT_MOTION"; //Step detector sensor case Sensor.TYPE_STEP_DETECTOR://18 return "TYPE_STEP_DETECTOR"; //Step counter sensor case Sensor.TYPE_STEP_COUNTER://19 return "TYPE_STEP_COUNTER"; //Geo-magnetic rotation vector case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR://20 return "TYPE_GEOMAGNETIC_ROTATION_VECTOR"; //Heart rate monitor case Sensor.TYPE_HEART_RATE://21 return "TYPE_HEART_RATE"; default:/*w w w . jav a2 s . co m*/ return UNKNOWN; } }
From source file:Main.java
/** * Returns true if at least one Accelerometer sensor is available *///w ww. jav a2s . c om public static boolean isSupported() { //Log.v(AccelerometerUtils.class.getClass().getCanonicalName(), "isSupported Accelerometer "+supported+" "+oContext); if (supported == null) { if (oContext != null) { sensorManager = (SensorManager) oContext.getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER); supported = new Boolean(sensors.size() > 0); } else { supported = Boolean.FALSE; } } return supported; }
From source file:MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mImageViewCompass = (ImageView) findViewById(R.id.imageViewCompass); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }
From source file:com.androtux.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); CommunicationHandler cHandler = CommunicationHandler.getInstance(); cHandler.setActivity(this); cHandler.initialize();//from w w w .j a v a 2 s . co m _sManager = (SensorManager) getSystemService(SENSOR_SERVICE); _maxRange = _sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER).getMaximumRange(); _multiplier = (1024 / _maxRange) * 4; _axis = false; }
From source file:eu.intermodalics.tango_ros_streamer.ImuNode.java
public ImuNode(Activity activity) { mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE); mRotationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); mGyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); mAccelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }
From source file:MainActivity.java
private void calculateCompassDirection(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: mAccelerationValues = event.values.clone(); break;/* w w w . j a v a 2 s .c om*/ case Sensor.TYPE_MAGNETIC_FIELD: mGravityValues = event.values.clone(); break; } boolean success = SensorManager.getRotationMatrix(mRotationMatrix, null, mAccelerationValues, mGravityValues); if (success) { float[] orientationValues = new float[3]; SensorManager.getOrientation(mRotationMatrix, orientationValues); float azimuth = (float) Math.toDegrees(-orientationValues[0]); RotateAnimation rotateAnimation = new RotateAnimation(mLastDirectionInDegrees, azimuth, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(50); rotateAnimation.setFillAfter(true); mImageViewCompass.startAnimation(rotateAnimation); mLastDirectionInDegrees = azimuth; } }
From source file:com.androtux.MainActivity.java
@Override protected void onResume() { super.onResume(); CommunicationHandler.getInstance().connect(); _sManager.registerListener(this, _sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); }
From source file:com.example.android.pdfrendererbasic.PdfRendererFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Retain view references. mPdfView = (PDFView) view.findViewById(R.id.pdfView); mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); accelerometerEventListener = new AccelerometerEventListener(mPdfView); mSensorManager.registerListener(accelerometerEventListener, mSensor, 20 * 1000);//20ms mPageIndex = 0;/* w w w . j a v a 2 s . co m*/ // If there is a savedInstanceState (screen orientations, etc.), we restore the page index. if (null != savedInstanceState) { mPageIndex = savedInstanceState.getInt(STATE_CURRENT_PAGE_INDEX, 0); } }