What is the exception? Is it possible the c.getColumnIndex() using the Phones.NUMBER is causing the exception? Can you wrap it in a try/catch block and show the exception?
On Tue, Dec 8, 2009 at 6:36 AM, Maurizio Bellemo <maurizio.bell...@gmail.com > wrote: > Hi all, > > I am developing an application with 2.0 sdk. I am trying to access the > contacts to get a number and send a SMS. > > *Intent intent = new Intent(Intent.ACTION_PICK, > > android.provider.ContactsContract.CommonDataKinds. Phone.CONTENT_URI); > startActivityForResult(intent, PICK_CONTACT);* > > Below you can find the code to catch the selected number > > *if (resultCode == Activity.RESULT_OK) { > Uri contactData = data.getData(); > Cursor c = managedQuery(contactData, null, null, null, > null); > if (c.moveToFirst()) { > String number = > c.getString(c.getColumnIndex(Phones.NUMBER)); > SmsManager sm = SmsManager.getDefault(); > sm.sendTextMessage(number, null, code, null, null); > setResult(RESULT_OK); > // finishes dialog activity > finish(); > } > }* > > The problem is that the highlighted line is not working. It triggers an > exception. Is there anything wrong in my way of using the contacts?? > > Any suggestion of how make it work? > > Thks > Bye > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > To post to this group, send email to android-beginners@googlegroups.com > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en