我正在处理文本到语音,在某些设备中它不起作用,因为用户已从应用程序管理器禁用Google文本到语音,有什么方法可以在发出文本到语音请求之前检查用户禁用应用程序的位置
我解决了我的问题,我知道这不是最好的解决方案,但对我来说它有效
textToSpeech = new TextToSpeech(context.getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
// for speak code goes here
} else {
Toast.makeText(context, "tts_failed Error code "+status, Toast.LENGTH_LONG).show();
if(status == -1) //
{
// this is will open play store if use have not install or disable google text to speach
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.tts")));
} catch (android.content.ActivityNotFoundException anfe) {
context. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.tts" )));
}
}
}