Content: // sms / sent / not working

This is the SMS observer code. I need to check only sent sms. When I use content://sms/ , I get the result. But why am I not getting results when I use content://sms/sent/ ? I am using Android 2.1.

 import android.app.Service; import android.content.ContentResolver; import android.content.Intent; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.util.Log; public class smsSentService extends Service { ContentResolver contentResolver; Uri uri=Uri.parse("content://sms/sent"); Handler handler; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { contentResolver=getContentResolver(); contentResolver.registerContentObserver(uri, true, new contentObserver(handler)); super.onCreate(); } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); } @Override public void onDestroy() { super.onDestroy(); } public class contentObserver extends ContentObserver { public contentObserver(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange) { Cursor cursor = contentResolver.query(uri, null, null, null, null); cursor.moveToFirst(); String content = cursor.getString(cursor.getColumnIndex("body")); Log.d("!!!!!!!!!!!!!", content); super.onChange(selfChange); } } } 
+6
source share
1 answer

Take a look at http://gbandroid.googlecode.com/svn-history/r46/trunk/MobileSpy/src/org/ddth/android/monitor/observer/AndroidSmsWatcher.java

This code listens for changes for all content: // sms and checks the type to see if it is a sent message.

+4
source

Source: https://habr.com/ru/post/906971/


All Articles