[Sony Ericsson XPERIA X10 Mini] JDRX:
Thanks for the feedback. That might very well be it. I've added a test command to echo something to a text file, which also doesn't work. However, the weird part is that it does seem to execute the "su" command, since it did ask for SuperUser permission the first time I ran it.

Which permission do I need to add in order to execute runtime tasks? I couldn't find anything about that and I've tried adding the permissions that I thought could be related, but it didn't work.

My manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[[the normal link here, which I can't post since I don't have 8 posts yet...:P]]"
package="com.x10mp.KBLight"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.hardware.sensor.light" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".KBLight"
android:label="@string/app_name"
android:configChanges="keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
</manifest>

I have also added a catch for SecurityException in the code, but it doesn't throw that.

Updated code:

package com.x10mp.KBLight;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
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 KBLight extends Activity {

private TextView tv;
private SensorManager mSensorManager;
private Sensor mLight;
private float light = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.testText);

mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);

if (mLight == null) {
tv.setText("No Light Sensor!");
} else {
mSensorManager.registerListener(lightSensorEventListener,
mLight,
SensorManager.SENSOR_DELAY_NORMAL);
}
}

SensorEventListener lightSensorEventListener = new SensorEventListener(){
@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}

@Override
public void onSensorChanged(SensorEvent arg0) {
// TODO Auto-generated method stub
if(arg0.sensor.getType()==Sensor.TYPE_LIGHT){
light = Float.valueOf(arg0.values[0]);
}
}
};

@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);

boolean kbOut = getResources().getConfiguration().hardKeyboardHidden==Configuration.HARDKEYBOARDHIDDEN_NO;
int i = (kbOut)?1:0;
tv.setText("Keyboard = " + kbOut + "\nLightstrength = " + light);
String[] commands = {"su",
"echo \"" + i + "\" >> /sys/devices/platform/msm_pmic_misc_led.0/brightness",
"echo \"test\" >> /sdcard/test.txt",
"exit"};

try {
Process process = Runtime.getRuntime().exec(commands);
tv.setText("Light set at \"" + i + "\"\nLightstrength = " + light);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
tv.setText("\nRUHROH! IOE ERROR:\n" + e.toString());
} catch (SecurityException e) {
tv.setText("\nRUHROH! SE ERROR:\n" + e.toString());
}

}
}