rootpanthera
rootpanthera

Reputation: 2771

App reads wrong sms

I want to read received text messages ( SMS ), as soon as they arrive (on received broadcast - android.provider.Telephony.SMS_RECEIVED) . I'm actually using following code, but it only reads message before the received. Anyone has idea why?

    public String getLastSms() {


    resolver = context.getContentResolver();
    uri = Uri.parse("content://sms/inbox");
    projection = new String[]{"body"};
    selection = null; 
    selectionArgs = null; 
    sortOrder = null;


    cursor = resolver.query(uri, projection, selection, selectionArgs, sortOrder);
    cursor.moveToFirst();

    return cursor.getString(0);

}

Upvotes: 0

Views: 43

Answers (1)

Snicolas
Snicolas

Reputation: 38168

You don't provide enough context. What does your receiver look like ? Did you look at a complete example like this one : http://www.tutos-android.com/broadcast-receiver-android ?

Upvotes: 1

Related Questions