Reading inbox SMS using Activity
Android Reading Inbox SMS
import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;
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);
}
}
Add below permission to AndroidManifest.xml
<uses-permission name="android.permission.READ_SMS" />
No comments:
Post a Comment