May I know why 'after speaking' event is chosen (to register with itoo) instead of 'before speaking' or something similar to 'currently speaking'? Why future tense is preferred (To achieve what specific result)?
Update: I can guess the answer for this question as the project is aiming to play some music after the text notifications are converted to speech. But, when I use the app, I can hear only the voice of the text notifications and no music is played after that. So, still I'm in doubt.
you ony can register those events, which exist... the text to speech component offers the BeforeSpeaking and AfterSpeaking event, see also the documentation Media
As the example is designed, first the notification will be spoken and after that a short sound will be played, therefore the AfterSpeaking event was registered to play the sound.
it is a short sound of 1 second, actually the sound of a frog...
which device and Android version are you using for your tests?
For your purposes to play some music after a message arrived, you do not have to register the text to speech event... just play your music in the OnNotificationReceived procedure.
This is a Samsung A20? Which Android version?
Working fine for me on Samsung Galaxy A54 running Android 14
You might want to check Samsung | Don’t kill my app!
EDIT: disable batttery optimization, see also
I noticed one thing. When we close the app and open it, we can see the quick shift of the message from ' Serivice is not running' to 'service is running'. So, it may mean that service is stop running while we close the app. But, I tested the older version of this app tutorial as well (that you posted before this one), it is working fine. Let me clarify again.
I screen recorded the video (You can see the quick shift of the message)
I tried the old version of this tutorial app once again. It can work even while we close the app. But, at beginning the app was not working, then I stopped the service and started again, after that it worked well.
@Taifun , I am speaking about the app given in this tutorial post. I tried the old version that is posted one day before as well. That one is working (while the app is closed) in my phone but this one is not working in background. I shall upload that video as well.
Update: Yes, there may not be relationship between clock component & background processing. Okay, let me check.
And as the initial text of version 2 is "service is NOT running", you see this quick flickering. Let me suggest you to change the initial value of that label to "Service is running" or just an empty text to see the difference.
It works fine,
but if multiple notification received at same time, it doesn't read notification one by one, it skips to the latest,
tried with TinyDB but it works only when the app is open,
yes, and as far as I can see everything you need is already there...
as @Kumaraswamy already mentioned, use the StoreProperty/FetchProperty methods rather than TinyDB
also there is no AfterSpeaking event in the background, therefore we registered that event using Itoo to use the afterSpeaking event handler (which looks like a procedure)...
and you might want to register another event, the Player1.Completed event, to continue with the next notification after the sound has been played
what you have to do is the following (pseudocode)
in the OnNotificationReceived event :
receive a message and store it using the StoreProperty method
get all received messages using the FetchProperty method
if there is only 1 message, speak it
in the afterSpeaking event handler:
play the sound
in the completed event handler:
delete the first message
check, if there are further messages stored, if yes, get the first message and speak it
In the screenshot I shared, you spoke about the way to achieve something when there is no required event in the blocks.
Here, in this case you registered the event with itoo which looks like procedure. But, when we build some other app which doesn't need background processing, Can we create our own event/event-handler (which may look like procedure) when the required events are not available in blocks?