Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Marking text message (SMS) unread

Tags:

android

sms

For some reason, NO sms app on android seem to offer the very basic feature (that even old dumb-phones have) of marking an SMS unread.

I am considerinng writing such an app myself, but before I begin I would like to know a little bit about how to do it and why it hasn't been done before. Surely it is not impossible?

like image 623
pinkfloydhomer Avatar asked Jun 19 '12 11:06

pinkfloydhomer


People also ask

Can you mark a text unread on Samsung?

You can mark any message as unread on Signal in the Android and iPhone versions of the secure-messaging app. Signal is available on Android, iPhone and desktop devices, but its desktop version lacks the ability to mark messages as unread.

How do you mark messages as unread on messages?

To mark the message unread, hold the arrow at the right that would be to open the message and read it. Start to swipe the message to the left and you will see a gray, orange and red box appear. If you swipe too far, you erase the message and will need to retrieve it from the Trash folder.

Why is my text showing an unread message?

If your Android is constantly notifying you of new or unread text messages that don't exist, it's usually due to your messaging app's cached or saved data. Sometimes these issues will clear up automatically upon receipt of a new message, so try asking someone to send you a message first.

What happens when you mark a message as unread?

The unread option will allow you to keep the message unread meaning it turns the seen message you received into the unread message. On your messenger, what you need to do is Tap and Hold on a chat and select the option Mark as unread.


2 Answers

NOTE: Firstly, just to let you know in Android it is little typical to work with Messaging System in Android(2.3 or lower) as to work with things like SMS requires to query with Content Providers which is officially not available and also Android guys have warned about it. You can check about it in the below URL: http://android-developers.blogspot.in/2010/05/be-careful-with-content-providers.html

Further for your solution and just for everybody's concern would like to divide my explanation according to Android OS versions:

- Version 2.3 or lower: Yes application is as simple to make as guided by Pankaj Kumar and it will work for the above mentioned Android OS version and lower.

- Version 4.0 & up: Application will fail and not work. Yes, as warned by Android Dev Guys, from this version and up, you will not be able to read Messaging contents as I have tried it so your application will not work on coming Android releases. You can only get the numbers of them like: inbox, sent, outbox failed etc... but you cannot modify or read contents.

- Version > 3.0 & < 4.0 : Never tested and tried.

Hope this information helps you and saves your time for going on a dead end route :)))

like image 124
abhy Avatar answered Sep 22 '22 19:09

abhy


Here you go

SMS Database has following Columns

06-19 17:41:19.723: V/vipul(25223): _id
06-19 17:41:19.723: V/vipul(25223): thread_id
06-19 17:41:19.723: V/vipul(25223): address
06-19 17:41:19.723: V/vipul(25223): person
06-19 17:41:19.723: V/vipul(25223): date
06-19 17:41:19.723: V/vipul(25223): protocol
06-19 17:41:19.723: V/vipul(25223): read
06-19 17:41:19.723: V/vipul(25223): status
06-19 17:41:19.723: V/vipul(25223): type
06-19 17:41:19.723: V/vipul(25223): reply_path_present
06-19 17:41:19.723: V/vipul(25223): subject
06-19 17:41:19.723: V/vipul(25223): body
06-19 17:41:19.723: V/vipul(25223): service_center
06-19 17:41:19.723: V/vipul(25223): locked
06-19 17:41:19.723: V/vipul(25223): error_code
06-19 17:41:19.723: V/vipul(25223): seen
06-19 17:41:19.723: V/vipul(25223): deletable
06-19 17:41:19.723: V/vipul(25223): hidden
06-19 17:41:19.723: V/vipul(25223): group_id
06-19 17:41:19.723: V/vipul(25223): group_type
06-19 17:41:19.723: V/vipul(25223): delivery_date
06-19 17:41:19.723: V/vipul(25223): date_sent

Below snippet marks all SMS as Unread you can chnage it to match the id and only make unread that SMS

package org.vipul;

import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

public class SMSSampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Uri uri = Uri.parse("content://sms/inbox");
        Cursor cursor = managedQuery(uri, null, null, null, null);

        for (int i = 0; i < cursor.getColumnCount(); i++) {
            Log.i("vipul", cursor.getColumnName(i));
        }

        if (cursor.moveToFirst()) {
            do {

                String id = cursor.getString(0);

                ContentValues contentValues = new ContentValues();
                contentValues.put("read", false);
                getContentResolver().update(uri, contentValues, "_id=?",
                        new String[] { id });
                contentValues.clear();
            } while (cursor.moveToNext());

        }
    }
}

Finally add android.permission.READ_SMS ans android.permission.WRITE_SMS in manifest

like image 39
Vipul Avatar answered Sep 24 '22 19:09

Vipul