2

I know that an incoming sms can be easily intercepted using a broadcast reciever. But I did not see any way to intercept an outgoing sms. How can this be done? But there is a way to do this.. Because many third party applications read both incoming and outgoing sms.

Vivek
  • 4,526
  • 17
  • 56
  • 69

1 Answers1

6

You will have to do something like this:

  1. Cache all messages's hash code on the phone
  2. Register an content observer for content://sms
  3. In onChange method of observer, enumrate all messages to check if it is in cache, if not, the message is sent out just now.

Good luck with your project :-)

Edit: md5 method
You can take the (arrival date + message) text to get a unique md5 output.

private String md5(String in) {
    MessageDigest digest;
    try {
        digest = MessageDigest.getInstance("MD5");
        digest.reset();        
        digest.update(in.getBytes());
        byte[] a = digest.digest();
        int len = a.length;
        StringBuilder sb = new StringBuilder(len << 1);
        for (int i = 0; i < len; i++) {
            sb.append(Character.forDigit((a[i] & 0xf0) >> 4, 16));
            sb.append(Character.forDigit(a[i] & 0x0f, 16));
        }
        return sb.toString();
    } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }
    return null;
}
Mark Mooibroek
  • 7,636
  • 3
  • 32
  • 53
  • Very good approach... By the way how do I store the hash codes of messages. I did not know till now, this could be possible. You help is very much appreciated. Thanks a lot. :-) – Vivek Apr 26 '11 at 09:11
  • You can use an md5 hash for example. Ill update my post with a Java md5 method. – Mark Mooibroek Apr 26 '11 at 09:52