For quite some time, I use a task to mark unread sms as read programmatically via Tasker. But these method worked not so effectively.
Firstly, I adopt the database-process-directly way. With a specific SQL syntax, I can mark all unread sms as read. Like this:
Run Shell [ Command: sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db "update sms set read=1 where read=0" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: Continue Task After Error:On ]
Yes, it mark the unread sms as read. But it can’t refresh the unread count in “Messaging” app. And it can’t clear the unread notification in notification bar.
Then I tried the “SL4A+Python” method(refer here). Yes, it can mark unread sms as read and reset the unread count in “Messaging App”. But it can’t clear the unread notification too.
With the “SL4A+Python” method, we made a step forward. But it’s not very perfect. As for notification problem, I had looked up some information. It’s not allowed to clear notification of other app programmatically in android. The notification can be cleared by the tapping of user or by the app itself. We will be taken to the main window of app when we tapped the specific notification normally. And it seems not to be a friendly way. So we can consider about the other way. But app will not clear its notification at our sweet will. I’ve been stuck here for a long time.
Until recently, the principle behind "Launch Camera App" inspired me to try to do something similar about the package of "Messaging" app.
I tried it and it proves me right on MIUI 3.9.6. Now I can mark unread sms as read thoroughly via Tasker! Here is the flowchart:
More: Clear An App's Notification
Showing posts with label package. Show all posts
Showing posts with label package. Show all posts
9/22/2013
9/18/2013
Launch App From Its Name
Long time ago, I want to launch app when AutoVoice recongnized the app name I said. Unfortunately, the "Launch App" will not support app name as variable at present. After some digging, I found a way out. Here it is.
A launcher is something similar with desktop shell in Windows, I think. You should know most app will leave its package information in the database of launcher when installed. So we can dive into the database of launcher and pull the specific information out. The figures below shows the database of MIUI launcher in my MIUI ROM. You can find the database in path /data/data/com.miui.home/databases/launcher.db.
In "Figure 3", the field "intent" is very important for us. We can launch app with "am start" command in Android shell. You can type "am start" command in shell to get detailed help of this command.
We can launch specific app with "am start" command when we extract useful intent information from corresponding "intent" field.
Here is one of my AutoVoice task which aimed to launch app from speech:
Task: LaunchApp
A1: Run Shell [ Command:sqlite3 /data/data/com.miui.home/databases/launcher.db "SELECT intent FROM favorites WHERE intent IS NOT NULL AND title LIKE '%%avcommnofilter%' LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Output In:%intent Store Errors In: Store Result In: ]
A2: If [ %intent Is Set ]
A3: Variable Search Replace [ Variable:%intent Search:#Intent;action= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:am start -a ]
A4: Variable Search Replace [ Variable:%intent Search:;category= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -c ]
A5: Variable Search Replace [ Variable:%intent Search:;launchFlags= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -f ]
A6: Variable Search Replace [ Variable:%intent Search:;component= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -n ]
A7: Variable Search Replace [ Variable:%intent Search:;end Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Run Shell [ Command:%intent Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
A9: Else
A10: Music Play [ File:Tasker/Notify/Dialog/sorry.wav Start:0 Loop:Off Stream:3 ]
A11: End If
Note:
1. Records are case-sensitive in SQLite database. My former task can not process this situation.
2. Few apps can't show on desktopof launcher, and even can't be found in launcher.db. You can't launch it in this way.
3. Although I talked here with taking the MIUI launcher as example, I think the principle will be same with other launcher. Maybe databases differ!
4. If you want do it with a separate app, you can try AutoLaunch(paid).
5. Some useful files for all packages installed: /data/system/packages.list /data/system/packages.xml
6. A useful command to list packages: "pm list packages -f"
A launcher is something similar with desktop shell in Windows, I think. You should know most app will leave its package information in the database of launcher when installed. So we can dive into the database of launcher and pull the specific information out. The figures below shows the database of MIUI launcher in my MIUI ROM. You can find the database in path /data/data/com.miui.home/databases/launcher.db.
Figure 1. tables in launcher.db
Figure 2. records in the table "favourites"
Figure 3. record of app named "SwipePad"
In "Figure 3", the field "intent" is very important for us. We can launch app with "am start" command in Android shell. You can type "am start" command in shell to get detailed help of this command.
Figure 5. "am start" command help
We can launch specific app with "am start" command when we extract useful intent information from corresponding "intent" field.
Here is one of my AutoVoice task which aimed to launch app from speech:
Task: LaunchApp
A1: Run Shell [ Command:sqlite3 /data/data/com.miui.home/databases/launcher.db "SELECT intent FROM favorites WHERE intent IS NOT NULL AND title LIKE '%%avcommnofilter%' LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Output In:%intent Store Errors In: Store Result In: ]
A2: If [ %intent Is Set ]
A3: Variable Search Replace [ Variable:%intent Search:#Intent;action= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:am start -a ]
A4: Variable Search Replace [ Variable:%intent Search:;category= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -c ]
A5: Variable Search Replace [ Variable:%intent Search:;launchFlags= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -f ]
A6: Variable Search Replace [ Variable:%intent Search:;component= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -n ]
A7: Variable Search Replace [ Variable:%intent Search:;end Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Run Shell [ Command:%intent Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
A9: Else
A10: Music Play [ File:Tasker/Notify/Dialog/sorry.wav Start:0 Loop:Off Stream:3 ]
A11: End If
Note:
1. Records are case-sensitive in SQLite database. My former task can not process this situation.
2. Few apps can't show on desktopof launcher, and even can't be found in launcher.db. You can't launch it in this way.
3. Although I talked here with taking the MIUI launcher as example, I think the principle will be same with other launcher. Maybe databases differ!
4. If you want do it with a separate app, you can try AutoLaunch(paid).
5. Some useful files for all packages installed: /data/system/packages.list /data/system/packages.xml
6. A useful command to list packages: "pm list packages -f"
Subscribe to:
Posts (Atom)







