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" <linke...@gmail.com> 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 <linke...@gmail.com> > > > you can use try catch, show your log. > > also, cursor should be close. have a try. > > > 2008/12/31 <ipeg.stud...@gmail.com> > > >> ################################################################### > >> 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 -~----------~----~----~----~------~----~------~--~---