I have an activity with a button. On ACTION_DOWN I start recording and keep on recording while pressing this button. On ACTION_UP I have to stop recording. Recording thread is separate one. There is a text view on the activity that shows the recording time. Default value for time is “00:00:00:000” From recording thread i m calling updateTime method of the activity class:
public void updateTime(final String time) {
Log.d("***UPDATE TIME Thread", "Current time:" + time);
runOnUiThread(new Runnable() {
public void run() {
timerTextView.setText(time);
Log.d("UPDATE TIME Thread", "Current time:"+time);
}
});
}
When I call this activity first time it work fine and update the time value properly. But if I select the same option from previous screen to start recording second time, the value of time text view remains same as “00:00:00:000” where as in second Log.d code line showing the proper value. Here is the LogCat
02-25 16:07:10.660: D/Recording(5075): Start
02-25 16:07:10.695: D/***UPDATE TIME Thread(5075): Current time:00:00:00:032
02-25 16:07:10.711: D/UPDATE TIME Thread(5075): Current time:00:00:00:032
02-25 16:07:10.843: D/***UPDATE TIME Thread(5075): Current time:00:00:00:174
02-25 16:07:10.863: D/UPDATE TIME Thread(5075): Current time:00:00:00:174
02-25 16:07:10.945: D/***UPDATE TIME Thread(5075): Current time:00:00:00:280
02-25 16:07:10.972: D/UPDATE TIME Thread(5075): Current time:00:00:00:280
02-25 16:07:11.082: D/***UPDATE TIME Thread(5075): Current time:00:00:00:418
02-25 16:07:11.089: D/UPDATE TIME Thread(5075): Current time:00:00:00:418
02-25 16:07:11.203: D/***UPDATE TIME Thread(5075): Current time:00:00:00:535
02-25 16:07:11.222: D/UPDATE TIME Thread(5075): Current time:00:00:00:535
02-25 16:07:11.351: D/***UPDATE TIME Thread(5075): Current time:00:00:00:676
......
Here is my Activity Class Code
public class VerficationPBActivity extends Activity implements VoiceManagerListener, OnTouchListener { private Claimant currentClaimant = null; TextView screenHeading = null; private String screenHeadingText = null; TextView textToSpeakTextView = null; TextView timerTextView = null; TextView statusHintTextView = null; private Button pushToRecordButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_verfication_pb);
ActivityController.getActivityController().setCurrentActivity(this);
screenHeading = (TextView) findViewById(R.id.screenHeading);
textToSpeakTextView = (TextView) findViewById(R.id.text_to_speek);
timerTextView = (TextView) findViewById(R.id.timer);
statusHintTextView = (TextView) findViewById(R.id.status_hint);
screenHeadingText = (String) getIntent().getSerializableExtra("heading");
currentClaimant = (Claimant) getIntent().getSerializableExtra("claimant");
screenHeading.setText(screenHeadingText);
if (currentClaimant != null) {
textToSpeakTextView.setText(currentClaimant.getNextPrompt());
statusHintTextView.setText(currentClaimant.getStatusHint());
}
pushToRecordButton = (Button) findViewById(R.id.pushToRecord);
pushToRecordButton.setOnTouchListener(this);
}
@Override
public void updateTime(final String time) {
Log.d("***UPDATE TIME Thread", "Current time:" + time);
runOnUiThread(new Runnable() {
public void run() {
timerTextView.setText(time);
Log.d("UPDATE TIME Thread", "Current time:"+time);
Log.d("UPDATE TIME Thread", "Current value:"+timerTextView.getText());
}
});
}
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
VoiceManager.getInstance().startRecording();
break;
case MotionEvent.ACTION_UP:
Log.d("Push Button Down", "Up Event Fired");
VoiceManager.getInstance().stop();
String audioDataBase64 = VoiceManager.getInstance().getAudioDateinBase64Encoding();
if (screenHeadingText.equals("Verification")) {
VBSServiceManager.getInstance().processVerification(currentClaimant, audioDataBase64);
} else {
VBSServiceManager.getInstance().processEnrollment(currentClaimant, audioDataBase64);
}
break;
}
return false;
}
}