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