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 disable. Show all posts
Showing posts with label disable. Show all posts
9/22/2013
Launch Camera App With Predefined Settings via Tasker
During the mid-autumn vacation, someone requested help in my QQ troop of Tasker (ID: 333174356), about how to launch camera app with predefined parameters(e.g. picture size, picture quality, and so on) for specific situation. Because of some other reason, I just give him an idea to try, and I haven’t put it into effect. After the vacation, I have chance to try my idea and it turns out the idea is right. Realized the principle behind the idea may be helpful to more similar situations, hereinafter I will explain the idea in detail, and take the “picture size” parameter of rear camera for example.
Firstly, we know that the “Media -> Take Photo” action will open the camera with custom parameters and then take photo automatically. Unfortunately, we can’t use this action to open the camera with custom parameters just for preview, then take photo manually.
I know a specific intent, which named “android.media.action.IMAGE_CAPTURE” in android, can launch the camera app with preview window. I’ve tried it before. And I find it not support camera parameters. I mean that it only open the camera window with default settings which we can’t change it programmatically.
Below shows the intent I tried:
Send Intent [ Action:android.media.action.IMAGE_CAPTURE Cat:Default Mime Type: Data: Extra: Extra: Package:com.android.camera Class:com.android.camera.Camera Target:Activity ]
As everyone knows, most settings are stored in the format of file, even databases. After some digging, I found the file (data/data/com.android.camera/shared_prefs/com.android.camera_xiaomi_preferences_0.xml) contains the “picture size” setting. We can change the value of “pref_camera_picturesize_key” node in the xml file programmatically. Then we launch the camera app. At last, we can restore the “picture size” setting.
Be careful! If you only follow these steps, the loaded camera app will not meet the desired effect. Because the camera app maybe can’t realize some settings changed, I think. There is a trick that you can disable and enable the app to take into effect. It’s very probably that the app will re-read the preferences file after the disable and enable operation. I guess the camera app read the settings and always runs in background when the device boots. We can disable and enable an app manually in android.
Of course, we can do this with the “Secure Setting” plugin for Tasker.
As for how to change the setting string in the preferences file, you can use shell script(especially “sed”, “awk” command) or use two files for renaming and swapping.
Here is the flowchart of the whole idea. (I've tried it successfully in MIUI 3.9.6)
Firstly, we know that the “Media -> Take Photo” action will open the camera with custom parameters and then take photo automatically. Unfortunately, we can’t use this action to open the camera with custom parameters just for preview, then take photo manually.
I know a specific intent, which named “android.media.action.IMAGE_CAPTURE” in android, can launch the camera app with preview window. I’ve tried it before. And I find it not support camera parameters. I mean that it only open the camera window with default settings which we can’t change it programmatically.
Below shows the intent I tried:
Send Intent [ Action:android.media.action.IMAGE_CAPTURE Cat:Default Mime Type: Data: Extra: Extra: Package:com.android.camera Class:com.android.camera.Camera Target:Activity ]
As everyone knows, most settings are stored in the format of file, even databases. After some digging, I found the file (data/data/com.android.camera/shared_prefs/com.android.camera_xiaomi_preferences_0.xml) contains the “picture size” setting. We can change the value of “pref_camera_picturesize_key” node in the xml file programmatically. Then we launch the camera app. At last, we can restore the “picture size” setting.
Be careful! If you only follow these steps, the loaded camera app will not meet the desired effect. Because the camera app maybe can’t realize some settings changed, I think. There is a trick that you can disable and enable the app to take into effect. It’s very probably that the app will re-read the preferences file after the disable and enable operation. I guess the camera app read the settings and always runs in background when the device boots. We can disable and enable an app manually in android.
Of course, we can do this with the “Secure Setting” plugin for Tasker.
As for how to change the setting string in the preferences file, you can use shell script(especially “sed”, “awk” command) or use two files for renaming and swapping.
Here is the flowchart of the whole idea. (I've tried it successfully in MIUI 3.9.6)
Subscribe to:
Posts (Atom)











