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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值