Skip to content

Instantly share code, notes, and snippets.

@TomTasche
Created April 24, 2012 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomTasche/2477850 to your computer and use it in GitHub Desktop.
Save TomTasche/2477850 to your computer and use it in GitHub Desktop.
Sample implementation for InfiniteWakefulIntentService
import android.content.Intent;
import com.announcify.uberall.droid.util.TextToSpeechHelper;
public class TextToSpeechService extends InfiniteWakelockIntentService {
private TextToSpeechHelper helper;
public TextToSpeechService() {
super("Announcify - Text-To-Speech");
}
@Override
public void onCreate() {
super.onCreate();
helper = new TextToSpeechHelper(this);
}
@Override
protected void onHandleIntent(Intent intent) {
helper.speak("hello");
}
@Override
protected boolean isFinished() {
return helper != null && helper.isReady() && helper.isFinished() && !helper.isSpeaking();
}
@Override
public void onDestroy() {
helper.stop();
super.onDestroy();
}
}
@TomTasche
Copy link
Author

This isn't very helpful since you don't know what TextToSpeechHelper is and does, but I think it gives you an idea of how isFinished() should be implemented: don't return true until you have finished all work, e.g. waiting for callbacks and the like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment