A profile to detect when a SMS database has been changed
http://webmail.dev411.com/t/gg/tasker/12bdddbsak/a-profile-to-detect-when-a-sms-has-been-sent
A belated reply. My solution below [let Tasker know when an SMS was sent]
follows Pent's outline.
Prereqs - you must:
0. be root
0. have sqlite3 installed
0. locate your message database (mmssms.db). Most likely this is in
</data/data/com.android.providers/telephony/databases/mmssms.db>
1. Create a Profile with the context of Application - Messages (or whichever SMS apps you care about).
2. On-entry task:
2a.- Script Action, Run Shell, Command:
- sqlite3 [your message db full path] SELECT MAX(_id) FROM sms ;
- store output in %PrevMaxMsg
3. On-exit task:
3a.- Script Action, Run Shell, Command:
- sqlite3 [your message db full path] SELECT MAX(_id) FROM sms ;
- store output in %NowMaxMsg
3b. - If %PrevMaxMsg !~ %NowMaxMsg:
3c. - [your actions]
This works because the mmssms.db database contains a table (sms) which
holds the details of sms and mms messages drafted, sent, received and
failed. Getting and comparing MAX(_id) on entry and exit lets you know if a
new message has been created.
4. Note with this approach "[your actions]" will also occur for a drafted,
unsent message - this may be undesirable. For more granularity:
- replace the SQL queries in 2a and 3a with something like "SELECT type,
COUNT(*) FROM sms GROUP BY type ;"
- This results in "1|47 2|43 3|1 6|1", which are message states and
counts "1. Inbox (Received) = 47; 2. Sent = 43; 3. Draft = 1; 6. Queued
(for Send) = 1". These counts could be used to drive different behaviours.
- I understood the message states from
<https://github.com/android/platform_frameworks_base/blob/ics-mr1-release/core/java/android/provider/Telephony.java>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本