###################################################################
Please help me access the list of sms in the inbox. I am using this
code, please let me know what is wrong, it always gives a n unexpected
error popup in the emulator.


I used a similar code for accessing the contacts list ( People.NAME
etc ), it worked fine. However, I cannot do it for SMS inbox.

Thanks in advance and happy new year!
###################################################################
package org.anddev.android.hello;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Telephony.Sms;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;

public class HelloAndroid extends ListActivity {

     private ListAdapter mAdapter;

      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        Cursor c = getContentResolver().query(Sms.Inbox.CONTENT_URI,
null, null, null, null);//.query(Sms.CONTENT_URI, null, null, null,
null);
        startManagingCursor(c);
        String[] columns = new String[]{Sms.Inbox.READ};
        int[] names = new int[]{R.id.row_entry};
        mAdapter = new SimpleCursorAdapter(this, R.layout.main, c,
columns, names);

        this.setListAdapter(mAdapter);
    }

 }
###################################################################

Here is the main.xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Name: "
    />
<TextView
    android:id="@+id/row_entry"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
</LinearLayout>

#####################################################################
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to