0
如何在語音運行時保持通知?如何關閉語音完成後的通知
主要活動:
TextToSpeech tts;
...
public void notification() {
NotificationCompat.Builder notification =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_volume_up_white_36dp)
.setOngoing(true)
NotificationManager NotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotifyMgr.notify(1, notification.build());
}
...
public void speak() {
tts=new TextToSpeech(getApplicationContext(),new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
notification(); //Call Notification
tts.setLanguage(Locale.US);
tts.speak("message", TextToSpeech.QUEUE_FLUSH, null);
}
});
}
什麼是貫徹落實通知需要取消行動,並應在何處進入
NotifyMgr.cancel(1);
我收到未知方法'isSpeaking' – Mssjim
適用於(!tts.isSpeaking)。 – Mssjim
太好了。 isSpeaking是布爾方法TextToSpeech類。如果TTS引擎正在講話,該方法返回true。和那個服務器你的要求我猜。 – iDevRoids