kunal
kunal

Reputation: 124

Unable to read the sms

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.

Upvotes: 2

Views: 94

Answers (1)

Ovi
Ovi

Reputation: 362

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

<uses-permission android:name="android.permission.READ_SMS" /> 

Upvotes: 1

Related Questions