Android Question APK FAILS when using TTS feature at Sub Activity_Create

Fsalcido888

New Member
Hi.... kind of new using B4A .... I'm trying to use TTS function on the very first opening screen which is call in Sub Activity_Create(FirstTime As Boolean).
The original sub contains only this :

Sub Activity_Create(FirstTime As Boolean)

Activity.RemoveAllViews
Activity.LoadLayout("HOME1")

End Sub.

But if I Add a TTS command after the activity load HOME1 and before the End Sub I will not get any error or syntax error but the created APK will fail (with no error message ) before showing anything on my phone

Guess I tried all possible commands I know and posted on this website and I cant get it to run,

1. The same layout HOME1 is loaded from other click menus and it works fine using TSS calls.
2. All Other menus and TSS calls works perfect without issues.

The Sub Activity_Create I created and ”fails” looks look like this:

Sub Activity_Create(FirstTime As Boolean)

Activity.RemoveAllViews
Activity.LoadLayout("HOME1")

TTS1.Speak("texto", True)
TTS1.Speak("mas texto", False)

End Sub



Thanks.
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
Welcome Fsalcido888 on this forum.
Hi.... kind of new using B4A .... I'm trying to use TTS function on the very first opening screen which is call in Sub Activity_Create(FirstTime As Boolean).
The original sub contains only this :
Firstly, you're suppose to use code tags </> to format the source:
My source:
Sub [B]Activity_Create[/B](FirstTime As Boolean)
      Activity.RemoveAllViews
      Activity.LoadLayout("HOME1")
End Sub

Secondly, the best thing you can do is made a small demo project which lead to your problem. I can't see which TTS library you use, nor how you initialize your TTS system.

Hi.... kind of new using B4A .... I'm trying to use TTS function on the very first opening screen which is call in Sub
But if I Add a TTS command after the activity load HOME1 and before the End Sub I will not get any error or syntax error but the created APK will fail (with no error message ) before showing anything on my phone
We need more sour code to see what you have or not have done.

Missing initialization:
Sub Activity_Create(FirstTime As Boolean)
    Activity.RemoveAllViews
    Activity.LoadLayout("HOME1")
    TTS1.Speak("texto", True)
    TTS1.Speak("mas texto", False)
End Sub
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
The file extension MP3 is just like cars, a container concept. You have many different types and versions, because the MP3 file may have a bitrate that is supported by one player and not by another. Just relying on the name is not enough.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tested your problem.
It seems that Android does not allow TTS.Speak in the Activity_Create routine.
Anyway, to me it does not make sense to speak any text when creating the Activity.
In Debug mode it throws an error java.lang.RuntimeException: Error speaking text.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("HOME1")
    
    TTS1.Initialize("TTS1")
    TTS1.Speak("texto", True)
    TTS1.Speak("mas texto", False)
End Sub

Then i tested the code in Activity_Resume, moving the two lines from Activity_Create to Activity_Resume.
It throws the same error.
B4X:
Sub Activity_Resume
    TTS1.Speak("texto", True)
    TTS1.Speak("mas texto", False)
End Sub

But, this one works:
B4X:
Sub Activity_Resume
    Sleep(0)
    TTS1.Speak("texto", True)
    TTS1.Speak("mas texto", False)
End Sub
 
Upvote 0
Top