如何检查用户是否从应用程序管理器禁用 Google 文本到语音
How to check if user disable Google text to speech from Application manager
我正在处理文字转语音,但在某些设备上它不起作用,因为用户从应用程序管理器禁用 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" )));
}
}
}
我正在处理文字转语音,但在某些设备上它不起作用,因为用户从应用程序管理器禁用 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" )));
}
}
}