[Java for Android App Development] spelaben:
Hi all, I'm fairly new to Java and my overall coding skills are not as advanced as I'd like them to be but I really would appreciate it if someone could help me with this problem. :)

My first goal is to code an application for Android which measures the acceleration (X, Y, Z directions) and displays the values in a TextView.

There will be other user configurable options like unit conversion or limits with audio warnings etc. later on.

Right now I only have a few lines of code and the application already force closes right after starting.

I am posting my MainActivity.java, my activity_main.xml and the sensoractivity2 Manifest. Please point me in the right direction!

MainActivity.java:

package com.example.sensoractivity2;

import android.app.Activity;
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 MainActivity extends Activity implements SensorEventListener{
private SensorManager sensorManager;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE);
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
}

public void onSensorChanged(SensorEvent event) {
float x, y, z = 0;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER) {
x=event.values[0];
y=event.values[1];
z=event.values[2];
TextView tx = (TextView) findViewById(R.id.textView1);
tx.setText((int) x);
TextView ty = (TextView) findViewById(R.id.textView2);
ty.setText((int) y);
TextView tz = (TextView) findViewById(R.id.textView3);
tz.setText((int) z);
}
}

[MENTION=439709]override[/MENTION]
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub

}
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="X-Wert" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Y-Wert" />

<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Z-Wert" />

</LinearLayout>

sensoractivity2 Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sensoractivity2"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="8"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name="com.example.sensoractivity2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>