0

I have to count all sent text messages (SMS) by user or by some other app.

My app will run as Service (in background) and count sent messages.

Finally, when number of sent messages is greater than some value, I'll trigger an action.

Any idea on this ?

thanks

Nikola Ninkovic
  • 1,252
  • 1
  • 12
  • 27
  • http://stackoverflow.com/questions/5878910/keeping-count-of-the-number-of-smss-sent-in-android take a look at this :) – Viking May 23 '12 at 15:48

2 Answers2

0

Yoc can count SMS Sent by user or any other Appliction on device from listening SMS ContentProvider by using ContentObserver

for complete example how you can register ContentObserver for SMS ContentProvider see in this post my answer

Community
  • 1
  • 1
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
  • Error in class SMSObserver on this line ----------------------------------------------------------------- Cursor cur = this.getContentResolver().query(uriSMSURI, null, null, null, null); //------------------------------------------------------------- The method getContentResolver() is undefined for the type SMSObserver – Nikola Ninkovic May 23 '12 at 16:19
  • ok fine edit your post with latest code bez this is working as you see my answer was accepted by another user – ρяσѕρєя K May 23 '12 at 16:21
  • Make sure you are creating this SMSObserver class inside your service or activity if you are creating outside from service,activity or broadcast receiver then you need to use current context instead of this.getContentResolver() so repace this line with Your_Current_Context.getContentResolver() – ρяσѕρєя K May 23 '12 at 16:31
  • There's a call to onChange() whenever I send SMS, but also, function is called on received SMS. – Nikola Ninkovic May 23 '12 at 21:27
  • Since google Play is trying to stop apps with READ_SMS permission unless for OTP or financial data purposes, I was wondering if there is another workaround for this. – midhunhk Mar 14 '19 at 22:36
0

This will be done by broadCastReceiver Check this Android - SMS Broadcast receiver

Community
  • 1
  • 1
Raheel
  • 4,953
  • 4
  • 34
  • 40