Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any other property of SMS will also get modify if user read the SMS(from native) excluding "read"?

Tags:

android

Is any other property of SMS will also get modify if user read the SMS(from native) excluding "read"?

For e.g.:

int read_status = cur1.getInt(cur1.getColumnIndex("read"));

read_status will become 1 for read SMS.

Please guide me.

like image 201
abhishek kumar gupta Avatar asked Nov 02 '22 12:11

abhishek kumar gupta


1 Answers

The code below will allow you to determine if any other properties besides “read” are changing by printing out the columns and corresponding values for all messages returned by the SMS Content Provider. Based on a quick test that I ran on a Nexus S running Android 4.1.2 JZO54K, it appears that unfortunately, there are no other values that are modified when an SMS changes from an unread to read state.

There is a related “seen” property which may be of interest, though. It changes from 0 to 1 when the SMS has been presented to the user but potentially before the message contents have been read (e.g., when displayed in the summary view of the native Messaging app). The relationship between "seen" and "read" can be further understood by looking through the uses in the com.android.mms.data.Conversation class.

The read state can also be retrieved using the android.telephony.SmsMessage.getStatusOnIcc() method, but that will likely give you the same info that you are already retrieving from the Content Provider. You may want to track the changes to the SMS APIs that Google is indicating will be coming in Android 4.4 (KitKat) since they could help with the problem you are trying to solve, but they could also break your existing implementation if it is relying on hidden APIs / Content Providers.

/* for use within a ContentObserver class; print all messages & fields
   from the SMS Content Provider when change to mmssms.db is detected;
   not optimized for production use */
   public void onChange(boolean selfChange) {
     super.onChange(selfChange);
     Uri uri = Uri.parse("content://sms/inbox");
     Cursor c= getContentResolver().query(uri,null,null,null,null);
     if(c.moveToFirst()){
       for(int i=0;i<c.getCount();i++){
         Log.d(TAG,"======= Message ID "+c.getString(c.getColumnIndexOrThrow("_id")).toString()+" ======="); 
         for (int j=0;j<c.getColumnCount();j++){
           Log.d(TAG,c.getColumnName(j)+" = "+c.getString(j));
         } 
       }
     }     
   }
 }
like image 166
ryanmac Avatar answered Nov 15 '22 06:11

ryanmac