- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个使用 TTS 的 Android Activity ,但是当我退出它时,在 Logcat 中出现泄漏的服务连接错误。在泄露的服务错误上方,我得到一条声明:
stop failed: not bound to TTS engine
shutdown failed: not bound to TTS engine
我的 onStop 和 onDestroy 看起来像这样:编辑代码:
@Override
public void onStop() {
if (tts != null) {
tts.stop();
}
super.onStop();
}
@Override
public void onDestroy() {
if (tts != null) {
tts.shutdown();
}
super.onDestroy();
}
我在用户按下按钮时触发了 TTS(TTS 工作正常,我只是想修复服务连接错误)
if (v == speakButton && ttscrashprotect == 1) {
String text = inputText.getText().toString();
if (text != null && text.length() > 0) {
tts.speak(text, TextToSpeech.QUEUE_ADD, null);
}
这是我的onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MY_DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
//sucess with TTS create it
tts = new TextToSpeech(this, this);
}
else {
//missing TTS so install it
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
}
TTS 工作正常,我可以看到引擎在 logcat 中被调用,但由于某些原因 tts.stop()
和 tts.shutdown()
不是绑定(bind)到同一个引擎。
EDIT2:看来我不止一次连接到 TTS 引擎和服务。每次我希望 TTS 在 Activity 中说出文本时,都会与 TTS 引擎和 TTS 服务建立另一个连接。
文本更改时我的 TTS 代码如下所示:
if (v==nextButton && progressL1<100) {
Video.setVisibility(View.INVISIBLE); //hide the video view
progressL1= progressL1 + 10;
//increase progress by 10 and then load the new files
//load the TTS text data from Asset folder progressL1 txt file
Advanced.this.loadDataFromAsset(progressL1);
//try some tts stuff here
Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
TTS 由上面的 v == speakButton
代码触发。
最佳答案
不要两次调用 tts.shutdown()
,在 onDestroy()
中就足够了。
@Override
public void onStop() {
if (tts != null) {
tts.stop();
}
super.onStop();
}
@Override
public void onDestroy() {
if (tts != null) {
tts.shutdown();
}
super.onDestroy();
}
关于android - 停止/关机失败 : not bound to TTS engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25426754/
在我的 root 用户 android 应用程序上,我使用 执行关机 su reboot -p 它工作正常,但我注意到手机几乎立即关机(而不是显示关机动画,并且可能在做其他事情)。 这是以编程方式关闭
我想创建一个流量小部件,并在每次设备关闭时存储使用的流量。问题是我无法触发关闭接收器。 我使用了以下代码: IntentFilter actionShutdown = new IntentFi
我在网上发现我可以安排 Windows 关闭: private void button1_Click(object sender, EventArgs e) { // Shutdown
是我可以调用的任何方法,它返回给我的信息是电话实际要关机(关机)。我知道这是 ACTION_SHUTDOWN 的 Intent ,但我必须从另一个来源获取有关关闭电话的信息。最好是直接形成系统。可能会
有没有办法在终止时运行代码,无论终止是什么类型(异常、正常、未捕获的异常等)?我知道它在 Java 中实际上是可能的,但它甚至可能在 C++ 中吗?我假设是 Windows 环境。 最佳答案 不——如
我希望我的应用程序可以防止 Windows 关闭。我知道有一个系统命令可以做到这一点。但不适用于我的程序。我使用此代码“取消”关闭的窗口: private void Form1_FormClosing
如何为我的应用暂停足够长的关机时间?我找到了一个 example ,但它适用于 Delphi - 我无法将其翻译成 C++。 最佳答案 这是 Delphi 代码的 C++Builder VCL 翻译:
我想知道当某个软件需要重新启动、关闭、注销或休眠 Windows 时,最佳做法是什么: 使用ExitWindowsEx API 使用关机命令及其参数 每种方法的优点和缺点是什么? 谢谢 最佳答案 我总
当我在虚拟机运行时尝试关闭 Windows 时,VMWare Workstation 的表现非常酷: 通常,我们会看到“此程序正在阻止 Windows 关闭”消息,而不是新的“1 个虚拟机正在使用中”
1、注销,关机,重启 注销系统的logout命令 1,Logout 注销是登陆的相对操作,登陆系统后,若要离开系统,用户只要直接下达logout命令即可: [root@localhost r
php 里面有个 system 方法, 可以调用系统命令。 先建立一个脚本(比喻 /root/reboot_server.sh ),重启用的。 复制代码代码如下: #!
我在戴尔 5000 游戏系列上安装了 Ubuntu 18.04,安装正常,然后在安装后提示重新启动。 重新启动登录屏幕后,我输入密码(为我在安装过程中创建的帐户)并按回车,但屏幕变为粉红色,几秒钟后它
我需要能够实现方法来防止这些情况发生: 关机 重启 注销 sleep 在 Mac 上,我使用的是 Xcode,但似乎无法找出执行这些操作的代码。 有人可以帮我从这里出去吗? 我发现了这个:http:/
我正在开发应用程序,我有一个要求:如果用户在任何时候长按电源按钮并再次按下以启动设备, Activity 应该从设备关闭的地方开始。我也不知道这个是不是一个有效的问题。我尝试使用: public cl
是否可以在所有网络接口(interface)停止之前检测到 Linux 中的系统关闭/重启?我可以处理 SIGTERM 信号并检查运行级别,但此时网络可能已经关闭。我需要 Python 脚本中的功能。
我目前正在开发一个小型但基本的应用程序,使用 tkinter 在我的 Windows 启动上运行,这样我就可以为我想要打开的不同内容提供一个小菜单。例如,我目前有启动我玩的一些游戏的按钮以及启动 Sk
我知道 shutdown -a 会中止 Windows 关机,但我需要知道是否有任何地方可以检查是否正在进行关机。 理想情况下,我想要一个像这样的小程序: import os while True
我试图在我的 c 程序中检测 Linux 的关闭或重启。我发现程序可以使用 signal(SIGTERM, handler) (SIGKILL, handler)。但是如果用户也使用命令终止进程,这两
我有这个工作的 Windows Server 2012 VM,需要重新启动。在我重新启动虚拟机后,更改了一些设置(连接了一个 DVD 驱动器),它会再次启动。 现在它说: Failed - The a
当我将应用程序设置为通过 docker-compose up 运行时,在 ctrl+c 上停止需要几秒钟。但是,如果我运行 docker kill ... ,容器很快停止。在 docker-compo
我是一名优秀的程序员,十分优秀!