Rotation Vector Sensor Android – Gyroscope

After messing around with sensors for a while and tried to see what TYPE_ROTATION_VECTOR actually returned as values. The docs seemed pretty sparse to me!

But whenever I tried to run a simple program to display the sensor output the activity crashed….due to a null pointer exception. Read a few posts and none was very clear….some mentioned that a gyroscope was needed…

Found this post which implies the device needs a gyroscope to implement a Rotation Vector Sensor.

Not 100% but as much information as I can find online!

Displaying a list of Sensors available on an Android device (Gingerbread) 2.3.3 used

Code below displays all available sensors (hardware and virtual)

import java.util.List;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class SensorListActivity extends Activity implements SensorEventListener {
	private SensorManager mSensorManager;
	private TextView mTextView;

	public void onCreate(Bundle savedInstanceState) {
		mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
		mTextView = (TextView) findViewById(;

		List<Sensor> mList
        = mSensorManager.getSensorList(Sensor.TYPE_ALL);
		for (int i = 1; i < mList.size(); i++) {
			mTextView.append("\n" + mList.get(i).getName());

	public void onAccuracyChanged(Sensor arg0, int arg1) {
		// TODO Auto-generated method stub


	public void onSensorChanged(SensorEvent event) {
		// TODO Auto-generated method stub 

	protected void onPause(){
	protected void onStop() {
	protected void onResume()


main.xml (just a textview to show the list of sensors)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

Sensors list displayed on Nexus One

Sensors list displayed on Nexus One

Starting… (again)

So my blogging starts again….this time it will last! and be here!

Hopefully will be aimed at Android development, Open Source projects, Hacking, Making, and Breaking!

Also interesting articles, funny things/issues I find, and about me and my research in general