package com.srinivas;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
import android.database.Cursor;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get sms from inbox
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
//
String sms = "";
while (cur.moveToNext()) {
sms += "" + cur.getString(3) + " : " + cur.getString(2);
}
TextView tv=(TextView)findViewById(R.id.textView1);
tv.setText(sms);
}
}
Manifest permission
<uses-permission android:name="android.permission.READ_SMS"/>
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
import android.database.Cursor;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get sms from inbox
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
//
String sms = "";
while (cur.moveToNext()) {
sms += "" + cur.getString(3) + " : " + cur.getString(2);
}
TextView tv=(TextView)findViewById(R.id.textView1);
tv.setText(sms);
}
}
Manifest permission
<uses-permission android:name="android.permission.READ_SMS"/>
0 coment�rios:
Post a Comment