Hi everyone and thank you for your support.
Today I have to manage this situation.
I need to perform an action when an SMS is received.
At the moment I use the notification on statusbar trigger from the default sms app to start the action.
The problem is that sometimes I receive the same SMS twice and I'd like to perform just one action , not two.
The two sms received are the same but coming from different numbers.
Most of the time the duplicated sms comes with a little delay time from the first one ( not more than 3 minutes) .
So hoe can I avoid to start the action when (if) the second sms arrives?
Anyone can help me ?
Thank you in advice.
Action on SMS received
Moderator: Martin
Re: Action on SMS received
Do you receive sms frequently? Or is this phone reserved to receive that sms only? If yes, the whole thing is simplified a lot. Since you only need to put sleep 3 minutes at the end of the flow and change the FEP to Skip.
But most likely you still receive other sms. So you have to create a kind of buffer to check if the last 3 minutes there is a similiar message.
To do this, you have to create a new global_smsbuffer with the type list. Just create it manually. Then make sure your flow FEP is parallel (if you never change it, is should be parallel by default). Now, check which part of the notification variable contain the things which is the same. Check which variable has the content of the message. You must check it by yourself. It maybe the notification_text. (I assume it is this one).
At the end of your flow, put action script to add this notification_text variable to the global_smsbuffer. Sleep for 3 minute and then remove it again after the time passed.
Then at the beginning of the flow, add expression between the trigger and main flow
Set your main flow to the false branch.
The concept of the buffer is to check if the incoming new message has the same content with the ones in the buffer. First message A, buffer is empty. So the expression will be evaluated to false, it will execute your main flow. At the end of the flow, this message A will be added to the buffer list and wait for 3 minutes. If no similiar message coming in 3 minutes, the buffer then removed after 3 minutes passed.
If there is new message B coming after 1 minute, it will be checked against the current buffer. Since it is B, evaluation will be false (the buffer only contain A). Main flow executed and in the end, B is added to buffer, wait another 3 minutes. Buffer now contain A and B. A has 2 minutes left, B is still fresh 3 minutes before get removed.
New message A come again after 2 minutes. It is checked against the buffer and found it in the buffer. Expression evaluated to true, and stop there. Main flow didn't get executed even though the flow got triggered. After first 3 minutes passed, A removed. B still has 1 minute left. If no more other B message coming, B got removed eventually and the buffer start from empty again.
But most likely you still receive other sms. So you have to create a kind of buffer to check if the last 3 minutes there is a similiar message.
To do this, you have to create a new global_smsbuffer with the type list. Just create it manually. Then make sure your flow FEP is parallel (if you never change it, is should be parallel by default). Now, check which part of the notification variable contain the things which is the same. Check which variable has the content of the message. You must check it by yourself. It maybe the notification_text. (I assume it is this one).
At the end of your flow, put action script to add this notification_text variable to the global_smsbuffer. Sleep for 3 minute and then remove it again after the time passed.
Code: Select all
addElement(global_smsbuffer, notification_text);
sleep(180000); //sleep 3 minute
removeElement(global_smsbuffer, 0); /after 3 minutes, remove it again
Code: Select all
containsElement(global_smsbuffer, notification_text)
The concept of the buffer is to check if the incoming new message has the same content with the ones in the buffer. First message A, buffer is empty. So the expression will be evaluated to false, it will execute your main flow. At the end of the flow, this message A will be added to the buffer list and wait for 3 minutes. If no similiar message coming in 3 minutes, the buffer then removed after 3 minutes passed.
If there is new message B coming after 1 minute, it will be checked against the current buffer. Since it is B, evaluation will be false (the buffer only contain A). Main flow executed and in the end, B is added to buffer, wait another 3 minutes. Buffer now contain A and B. A has 2 minutes left, B is still fresh 3 minutes before get removed.
New message A come again after 2 minutes. It is checked against the buffer and found it in the buffer. Expression evaluated to true, and stop there. Main flow didn't get executed even though the flow got triggered. After first 3 minutes passed, A removed. B still has 1 minute left. If no more other B message coming, B got removed eventually and the buffer start from empty again.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Action on SMS received
Desmanto, really thank you for your patience to answer me .
I've read accurately your answer : I don't know if my poor knowledge allow to build a flow like that,
but reading your answer I thought there's another way (more rough and stupid) that could work.
When an sms arrive I must check an App (that I will call "k") to see what happened;
K is an app wich has all the right information ( not duplicate ) in real time, so the sms
has been sent to me just to push me to check what happened on K.
So :
1) when an sms arrive I could check the content, open ( or ignore) automatically K and disable the flow
(if another sms arrive I can check what happened directly on K in real time)
2) after checked , when I close K , the flow can be enable itself again and all the notification (sms) deleted
It look more simple to me to build, do you think could work?
I've read accurately your answer : I don't know if my poor knowledge allow to build a flow like that,
but reading your answer I thought there's another way (more rough and stupid) that could work.
When an sms arrive I must check an App (that I will call "k") to see what happened;
K is an app wich has all the right information ( not duplicate ) in real time, so the sms
has been sent to me just to push me to check what happened on K.
So :
1) when an sms arrive I could check the content, open ( or ignore) automatically K and disable the flow
(if another sms arrive I can check what happened directly on K in real time)
2) after checked , when I close K , the flow can be enable itself again and all the notification (sms) deleted
It look more simple to me to build, do you think could work?
Re: Action on SMS received
Sorry to complicate it up
It is actually part of buffer script in my multiclipboard flow. Except I don't use timer.
In short :
1. Sms arrive, open app K.
2. When K is still open, ignore any incoming sms, remove the notification
3. If K is closed, accept any incoming sms again.
If that is, it is much simple. Ignore my buffer method above. No need to disable the flow. Simply add new condition : App Task Running : App K. If False, continue the branch to your main flow (open K and continue the flow). If true, continue to true branch and only remove the sms notification. So you only need to add 1 condition and 1 action.
The concept is easier. When first sms arrived, check if K is opened. Of coz, it is not yet (false), so the flow continue to open it. Next sms arrive, the K is now in open state, so condition continue to true; only remove the sms notif.

In short :
1. Sms arrive, open app K.
2. When K is still open, ignore any incoming sms, remove the notification
3. If K is closed, accept any incoming sms again.
If that is, it is much simple. Ignore my buffer method above. No need to disable the flow. Simply add new condition : App Task Running : App K. If False, continue the branch to your main flow (open K and continue the flow). If true, continue to true branch and only remove the sms notification. So you only need to add 1 condition and 1 action.
The concept is easier. When first sms arrived, check if K is opened. Of coz, it is not yet (false), so the flow continue to open it. Next sms arrive, the K is now in open state, so condition continue to true; only remove the sms notif.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Action on SMS received
Yes, I will this way, really thank you!