Note that there are some explanatory texts on larger screens.

plurals
  1. POContacts wont show up into EditText
    primarykey
    data
    text
    <p>I have an application that is supposed to call the contacts phone number into the designated EditText View. I have the button that calls up the contact picker and it works fine but when I click on it it doesn't add the information that I want into the View.</p> <p><strong>MY ONCLICKlISTENER</strong></p> <pre><code> public void pickContact(View view) { Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(contactPickerIntent, GET_CONTACT); } </code></pre> <p><strong>MY STARTACTIVITYFORRESULT</strong></p> <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { switch (requestCode) { case GET_CONTACT: Cursor cursor = null; String Number = ""; try { Uri result = data.getData(); Log.v(NOTIFICATION_SERVICE, "Got a contact result: " + result.toString()); // get the contact id from the Uri String id = result.getLastPathSegment(); // query for everything email cursor = getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null); int emailIdx = cursor.getColumnIndex(Phone.DATA); // let's just get the first email if (cursor.moveToFirst()) { Number = cursor.getString(emailIdx); Log.v(NOTIFICATION_SERVICE, "Got number: " + Number); } else { Log.w(NOTIFICATION_SERVICE, "No results"); } } catch (Exception e) { Log.e(NOTIFICATION_SERVICE, "Failed to get number data", e); } finally { if (cursor != null) { cursor.close(); } EditText mNumbers = (EditText)findViewById(R.id.editNumber); mNumbers.setText(Number); if (Number.length() == 0) { Toast.makeText(this, "No number found for contact.", Toast.LENGTH_LONG).show(); } } break; } } else { Log.w(NOTIFICATION_SERVICE, "Warning: activity result not ok"); } } </code></pre> <p>Thanks for any help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload