Detecting SMS incoming and outgoing
Asked Answered
L

2

21

I'd like to detect sms incoming and outgoing automatically from my application at background whenever this app is opening or not. how to code?

Lint answered 29/4, 2010 at 7:50 Comment(1)
I am doing something similar HERE!!! #14453308Whereupon
B
28

This is a good tutorial on both sending and receiving sms messages: http://mobiforge.com/developing/story/sms-messaging-android .

For the incoming messages you can indeed configure a broadcastlistener for detection. *

Detecting outgoing messages is also possible (just altered this post since I dind't know this). from: http://www.mail-archive.com/[email protected]/msg26420.html

ContentResolver contentResolver = context.getContentResolver();
  contentResolver.registerContentObserver(Uri.parse("content://
sms"),true, myObserver);
Bigamous answered 29/6, 2010 at 13:50 Comment(4)
Hey can you post your complete solution?Popp
Beginning with API level 19, the URI is added to the API and you get use Telephony.Sms.CONTENT_URI instead of Uri.parse("content:// sms").Wantage
@Lint can you post solution please?Stypsis
If we register with content://sms than its called even on Message is deleted. How do I specifically detect if its SENT msg only. Also in my device content change for content://sms/sent is not triggered.Squad
H
1

System broadcasts appropriate messages when messages are sent and received. You will have to create BroadCastReceiver for appropriate Intents(see documentation for details ... I think it is android.provider.Telephony.SMS_RECEIVED for interception not sure of sending though)

Halloo answered 29/4, 2010 at 10:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.