Fixing TTS initialization.

This commit is contained in:
Rodrigo Damazio
2010-11-20 05:43:09 -08:00
parent 898863a8d9
commit 77479efaef
4 changed files with 11 additions and 2 deletions
@@ -44,7 +44,8 @@ public class SignalStrengthTask extends PhoneStateListener
public SignalStrengthTask(Context c) {
context = c;
}
@Override
public void start() {
manager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
@@ -176,6 +177,7 @@ public class SignalStrengthTask extends PhoneStateListener
}
}
@Override
public void shutdown() {
if (manager != null) {
manager.listen(this, PhoneStateListener.LISTEN_NONE);
@@ -218,6 +218,7 @@ public class StatusAnnouncerTask implements PeriodicTask {
@Override
public void start() {
Log.i(MyTracksConstants.TAG, "Starting TTS");
if (tts == null) {
// We can't have this class also be the listener, otherwise it's unsafe to
// reference it in Cupcake (even if we don't instantiate it).
@@ -243,6 +244,8 @@ public class StatusAnnouncerTask implements PeriodicTask {
tts.shutdown();
tts = null;
}
Log.i(MyTracksConstants.TAG, "TTS shut down");
}
/**
@@ -49,7 +49,8 @@ public class TaskExecuterManager {
*/
public void setFrequency(int frequency, TrackRecordingService service) {
this.frequency = frequency;
Log.i(MyTracksConstants.TAG, "Frequency set to: " + frequency);
Log.i(MyTracksConstants.TAG, "Frequency set to " + frequency
+ " for task " + task.getClass().getSimpleName());
if (frequency == -1) {
if (executer != null) {
@@ -679,6 +679,9 @@ public class TrackRecordingService extends Service implements LocationListener {
if (announcer == null) {
return;
}
// TODO: Either use TaskExecuterManager everywhere, or get rid of it
announcer.start();
announcementExecuter = new PeriodicTaskExecuter(announcer,
TrackRecordingService.this);
}