android - select a contact and get phone number and call it -


When I click on a contact, I do not get a phone number, I only get a contact name, but no number No. I was sent for a related post but still not satisfied, please guide me.

My code is as follows:

  package com.Call_setup; Import android App Import android.content.ActivityNotFoundException; Import android.content.ContentResolver; Import android.content.Intent; Import android.database.Cursor; Import android.net.Uri; Importroid.os.Bundle; Import android.provider.Contacts.People; Import android.provider.ContactsContract; Import android.widget.ListAdapter; Import android.widget.TextView; The public class extends call_setup activity {/ ** is called when activity has been created first. * / Intent column; Personal list adapter mAdapter; PbContact public text view; Public stable string PBCONTACT; Public stable final distance ACTIVITY_EDIT = 1; Personal fixed final distance ACTIVITY_CREATE = 0; Private static final difference PICK_CONTACT = 0; Private static final difference PICK_CONTACT_REQUEST = 2; String id; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); Pu ka Raya na (); // onReiveive (this, callIntent); Incoming caller ICC = new incoming caller receiver (); Ic.onReceive (getApplicationContext (), callIntent); } Private Zero Call () {try {// intent callIntent = new intent (Intent.ACTION_CALL); / * Intent column = new intent (Intent.ACTION_PICK, people.contENT_URI); CallIntent.setData (Uri.parse ("tel: 123456")); StartActivity (callIntent); // Stop service (callinant); * / Intent Intent = New Intent (Intent.ACTION_PICK, People. CONTENT_URI); StartActivityForResult (Intention, PICK_CONTACT); } Catch (activitonephide exception exception exception exception) {// Log.e ("Halo-Android dialing example", "Call failed", e); }} @ Override Active Zero on Active Result (result code, intent data for int record, int) {super.onActivityResult (reqCode, resultcode, data); ContentResolver cr = getContentResolver (); Switch (case) {case (PICK_CONTACT): if (resultCode == activity. RESULT_OK) {URI contactData = data.getData (); Cursor c = managed query (contact data, empty, null, empty, zero); If (c.moveToFirst ()) {string name = c.getstring (c.getColumnIndexOrThrow (People.Phones.NAME)); String contact id = cgetstring (c .getColumnIndex (contactsContract.Contacts._ID)); // intimate collant = new intent (Intent.ACTION_CALL); System.out.println ("number is key:" + name); System.out.println ("reqCode:" + reqCode); System.out.println ("resultcode is:" + resultcode); System.out.println ("The contact ID is:" + contactId); // String Phononumber = C. Gastestring (C.Gate column index (ContactContact.com.CommentIndex.one NUMBER)); /*callIntent.setData(Uri.parse("tel:"+number);) Callinant; * /}} the break; }}} / * Public vacancies on Reciever (reference reference, intent to intent) {MyPhoneStateListener phoneListener = New MyPhoneStateListener (); Telephony Manager Telephony = (Telephony Manager) context.getSystemService (context.TELEPHONY_SERVICE); Telephony.listen (Phone Listener, Phonestate Listener. LISTEN_CALL_STATE); * / / * Public vacancies (final reference reference, final purpose intent) on resizing {Log.i ("l", "onreceive ()"); Logs. I ("l", "context:" + reference); Logs. I ("l", "intent:" + intent); If (intent.getAction (.) Equals (Intent.ACTION_NEW_OUTGOING_CALL)) {string number = intestine .getExtras (). GetString (Intent.EXTRA_PHONE_NUMBER); Logs. I ("l", "number:" + number); }}   

  cursor phone = etContentResolver () .query (ContactsContract CommandsDecondus.phone.contentorsi, blank, contactContact.comCommentIndones.ContacT_ID + "=" + contact ID, empty, empty); While (phones.moveToNext ()) {string phonenumber = phones. Gate string (phone.get column index (contactctact.com.comdemand.info.)); }    

Comments