Sometimes returning null when initializing tts But it only happens on Samsung devices I also added the following to the manifest, but the result is the same
Can't catch error even with try catch
Do you have any way to solve this problem? compileSdkVersion and targetSdkVersion are 30
<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>
tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR)
{
tts.setLanguage(Locale.US);
}
}
});
Attempt to invoke virtual method 'int android.speech.tts.TextToSpeech.setLanguage(java.util.Locale)' on a null object reference