Created
April 24, 2012 08:23
-
-
Save TomTasche/2477850 to your computer and use it in GitHub Desktop.
Sample implementation for InfiniteWakefulIntentService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.