Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting SMS incoming and outgoing

Tags:

android

sms

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?

like image 470
soclose Avatar asked Apr 29 '10 07:04

soclose


2 Answers

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);
like image 141
hcpl Avatar answered Oct 29 '22 00:10

hcpl


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)

like image 43
Samuh Avatar answered Oct 29 '22 01:10

Samuh