Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@TomTasche TomTasche commented Apr 24, 2012

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