ReadReminderTextService.java
package com.sudogeeks.talking_reminder;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.speech.tts.TextToSpeech;
import java.util.Locale;
public class ReadReminderTextService extends Service implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener {
private TextToSpeech mTts;
private String spokenText;
@Override
public void onCreate() {
mTts = new TextToSpeech(this, this);
// This is a good place to set spokenText
// spokenText="raushan raushan raushan raushan";
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
spokenText = intent.getStringExtra("MyTitle");
return START_STICKY;
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = mTts.setLanguage(Locale.US);
if (result != TextToSpeech.LANG_MISSING_DATA && result != TextToSpeech.LANG_NOT_SUPPORTED) {
mTts.speak(spokenText, TextToSpeech.QUEUE_ADD, null);
}
}
}
@Override
public void onUtteranceCompleted(String uttId) {
stopSelf();
}
@Override
public void onDestroy() {
if (mTts != null) {
mTts.stop();
mTts.shutdown();
}
super.onDestroy();
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
com.sudogeeks.talking_reminder.ReadReminderTextService.onCreate
void onCreate()
Definition: ReadReminderTextService.java:22
com.sudogeeks.talking_reminder.ReadReminderTextService.onInit
void onInit(int status)
Definition: ReadReminderTextService.java:48
com.sudogeeks.talking_reminder.ReadReminderTextService
Class for Text to speech service This class is extending the tts module service to speak up the remin...
Definition: ReadReminderTextService.java:13
com.sudogeeks.talking_reminder.ReadReminderTextService.onStartCommand
int onStartCommand(Intent intent, int flags, int startId)
Definition: ReadReminderTextService.java:37