I ran into something similar and I needed to tell the manifest to use
the right permission.  Check your android manifest and make try
something like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.app.you.package"
      android:versionCode="1"
      android:versionName="1.0.0">
    <uses-permission android:name="android.permission.READ_SMS" />
    <!-- Your other stuff goes here -->
</manifest>

Here is a good list of the app permissions:
http://code.google.com/android/reference/android/Manifest.permission.html

You definitely want to try debugging and don't forget to use
android.util.Log

On Dec 31 2008, 2:52 pm, moazzamk <[email protected]> wrote:
> You can generally catch the errors in your code by putting it in try
> and catch block. Here's a tutorial on the whole process of debugging
> in Android :http://moazzam-khan.com/blog/?p=41
>
> - Moazzam
>
> On Dec 31, 7:18 am, "linker lv" <[email protected]> wrote:
>
> > Uri uri = Uri.parse("content://sms/undelivered");
>
> >             // Perform a managed query. The Activity will handle closing and
> > requerying the cursor
> >             // when needed.
> >             Cursor cursor = getContentResolver().query(uri, null, null,
> > null,null);
> >             startManagingCursor(cursor);
> >             int[] names = new int[]{R.id.row_entry};
> >             String[] columns = new String[]{"body"};
> >             // Used to map notes entries from the database to views
> >             SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
> > R.layout.main, cursor,
> >                     columns, names);
> >             setListAdapter(adapter);
>
> > main.xml
> > <?xml version="1.0" encoding="utf-8"?>
> > <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:layout_width="fill_parent"
> >     android:layout_height="wrap_content"
> >     android:text="@string/hello"
> >     android:id="@+id/row_entry"/>
>
> > </LinearLayout>
>
> > *make sure that there is data in "content://sms/undelivered".*
> > public String strUriInbox = "content://sms/inbox";//SMS_INBOX:1
> >     public String strUriFailed = "content://sms/failed";//SMS_FAILED:2
> >     public String strUriQueued = "content://sms/queued";//SMS_QUEUED:3
> >     public String strUriSent = "content://sms/sent";//SMS_SENT:4
> >     public String strUriDraft = "content://sms/draft";//SMS_DRAFT:5
> >     public String strUriOutbox = "content://sms/outbox";//SMS_OUTBOX:6
> >     public String strUriUndelivered =
> > "content://sms/undelivered";//SMS_UNDELIVERED
> >     public String strUriAll = "content://sms/all";//SMS_ALL
> >     public String strUriConversations = "content://sms/conversations";//you
> > can delete one conversation by thread_id
> > "content://sms"//you can delete one message by _id
>
> > 2008/12/31 linker lv <[email protected]>
>
> > > you can use try catch, show your log.
> > > also, cursor should be close. have a try.
>
> > > 2008/12/31 <[email protected]>
>
> > >> ###################################################################
> > >> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to