I have this code:
public class Chronom extends Activity
{
Chronometer mChronometer;
ProgressBar progre;
int total=1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//layout
setContentView(R.layout.main7watingscreen);
//Start Chronometer
mChronometer = (Chronometer) findViewById(R.id.chrono1);
mChronometer.start();
progre = (ProgressBar) findViewById(R.id.progressBar1);
MyCount counter = new MyCount(31000,300);
counter.start();
}
public class MyCount extends CountDownTimer
{
public MyCount(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish()
{
Intent myIntent = new Intent( Chronom.this, MainMenu.class);
startActivityForResult(myIntent, 0);
}
@Override
public void onTick(long millisUntilFinished)
{
total++;
progre.setProgress(total);
}
}
and i want to store accelerometer values (x, y and z) inside a vector for example (can be other form i want to know your opinion).
But i want to do this at the same time as the progress bar is fulling ( it stops after 30 sec). Like begin the storing at 1 sec and stop after 30 sec.
If you don’t understand my question please say it and i will explain it better.
How to do it?? Please help!
You obtain sensor values every time they’re changed, through the
onSensorChanged()callback (see the SensorListener reference). You can’t query the sensor data at a set time.There is a way around that: have a listener saving the values every time they change (i.e., inside the
onSensorChanged()method), and query those saved values using your timer. For example, you can use astatic float[]array for it orSharedPreferencesvalues.