2

this is my code

public class SMSRead extends Activity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      TextView view = new TextView(this);
      Uri uriSMSURI = Uri.parse("content://sms/inbox");
      Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
      String sms = "";
      while (cur.moveToNext()) {
          sms += "From :" + cur.getString(2) + " : " + cur.getString(11)+"\n";         
      }
      view.setText(sms);
      setContentView(view);
  }
}

I tried with this code.But did not get the SMS in my app.

Ovi
  • 362
  • 3
  • 16
kunal
  • 124
  • 13
  • 1
    Possible duplicate of [how can i read inbox in android mobile?](http://stackoverflow.com/questions/5547352/how-can-i-read-inbox-in-android-mobile) – Devrim Nov 24 '16 at 10:10

1 Answers1

1

check the SMS_READ_PERMISSION in android manifest file . i think the code is ok .

<uses-permission android:name="android.permission.READ_SMS" /> 
kunal
  • 124
  • 13
Ovi
  • 362
  • 3
  • 16