Can I somehow get the number of unread SMS? Would be awesome!
In my current flow the loop goes forever when I have read an SMS myself upon arrival. I need a condition for counting the number of unread SMS to stop the flow.
Any ideas?
Get number of unread SMS
Moderator: Martin
Re: Get number of unread SMS
No, it's probably not possible yet.
You could use a trigger App Task Started and assume that all SMS have been read after you are closing the SMS app again.
You could use a trigger App Task Started and assume that all SMS have been read after you are closing the SMS app again.
-
- Posts: 27
- Joined: 04 Feb 2014 09:19
Re: Get number of unread SMS
Hmmm, why is this not possible yet?
And I am sorry, I cannot follow your suggestion with the App Task Started.
My goal is to write a flow where you get notified for unread SMS messages forever until there are none left. In that loop the screen flashes and the phone vibrates every 15 min. And a dialog appears which asks you if you want to read the message now or later.
How would you do that?
And I am sorry, I cannot follow your suggestion with the App Task Started.
My goal is to write a flow where you get notified for unread SMS messages forever until there are none left. In that loop the screen flashes and the phone vibrates every 15 min. And a dialog appears which asks you if you want to read the message now or later.
How would you do that?
Re: Get number of unread SMS
This feature is not available because the SMS database was not officially available to Android developers until Android 4.4 so this feature had a low priority.
My suggestion was meant as some sort of a workaround. When you get an SMS it can be considered unread until you open the SMS app. Of course this won't work when you get 10 SMS, read one and close the SMS app again.
If your device is rooted it might be possible to use the following command to get the unread message count (only tested on Android 4.4):
Execute Root Command: content query --uri content://sms/inbox --where "read=0" --projection "count(*)"
Variable stdout will contain a value like: Row: 0 count(*)=8.
You can use an action Script to extract the number:
My suggestion was meant as some sort of a workaround. When you get an SMS it can be considered unread until you open the SMS app. Of course this won't work when you get 10 SMS, read one and close the SMS app again.
If your device is rooted it might be possible to use the following command to get the unread message count (only tested on Android 4.4):
Execute Root Command: content query --uri content://sms/inbox --where "read=0" --projection "count(*)"
Variable stdout will contain a value like: Row: 0 count(*)=8.
You can use an action Script to extract the number:
Code: Select all
unread_count=substring(stdout, indexOf(stdout, "=")+1);
-
- Posts: 27
- Joined: 04 Feb 2014 09:19
Re: Get number of unread SMS
Mhhh, I have Android 4.2.1 rooted.
Is there a way I can test the command "content query --uri content://sms/inbox --where "read=0" --projection "count(*)" on a console in my phone first before I go ahead?
Or can you share a flow here and I quickly test it on my phone?
Thanks so much!
Is there a way I can test the command "content query --uri content://sms/inbox --where "read=0" --projection "count(*)" on a console in my phone first before I go ahead?
Or can you share a flow here and I quickly test it on my phone?
Thanks so much!
Re: Get number of unread SMS
The flow is called Show unread SMS count and will be imported into group __test:
http://automagic4android.com/flow.php?i ... 8720f63189
The first action queries the database then the flow uses a script to extract the number from the text (function trim is required because the text returned by the database ends with a newline character). The number of unread SMS will be stored in a variable called unread.
The third action shows the number as a notification on the screen.
You could also use a condition Expression: unread>0 to test if there are unread messages available.
http://automagic4android.com/flow.php?i ... 8720f63189
The first action queries the database then the flow uses a script to extract the number from the text (function trim is required because the text returned by the database ends with a newline character). The number of unread SMS will be stored in a variable called unread.
The third action shows the number as a notification on the screen.
You could also use a condition Expression: unread>0 to test if there are unread messages available.
-
- Posts: 27
- Joined: 04 Feb 2014 09:19
Re: Get number of unread SMS
Thanks, it works! 
