SMS Inbox Demo
package app.test;
import android.app.ListActivity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;
public class SMSInboxDemo extends ListActivity {
private ListAdapter adapter;
private static final Uri SMS_INBOX = Uri.parse("content://sms/inbox");
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Cursor c = getContentResolver()
.query(SMS_INBOX, null, null, null, null);
startManagingCursor(c);
String[] columns = new String[] { "body" };
int[] names = new int[] { R.id.row };
adapter = new SimpleCursorAdapter(this, R.layout.main, c, columns,
names);
setListAdapter(adapter);
}
}
//main.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This file is /res/layout/sms_inbox.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/row"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Related examples in the same category