Thanks in advance.
I m working in game application using accelerometer. but i've facing a problem, when i update textview in "onSensorChange" method of accelerometer.application not perform good.
My code like this.
int nCounter = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTV_CountTextView = (Textview)findViewById(R.id.TextView);
}
.... ......
public void onSensorChanged(SensorEvent sensorEvent) {
{
if (sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION) {
// Set sensor values as acceleration
yAcceleration = sensorEvent.values[1];
xAcceleration = sensorEvent.values[2];
nCounter++;
mTV_CountTextView.settext(""+nCounter);
}
}
}
See Question&Answers more detail:os