Note that there are some explanatory texts on larger screens.

plurals
  1. POGetAndroid contact information (phone, name, etc...)
    primarykey
    data
    text
    <p>I know you might think this subject has been treated several times but this is different!</p> <p>My app is supposed to get contact information (name, number) from a picked contact but I only get the name and I can't get the number.</p> <pre><code>@Override public void onClick(View v) { // Opening Contacts Window as a Window Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); // calling OnActivityResult with intent And Some contact for Identifie startActivityForResult(contactPickerIntent, PICK); } @Override public void onActivityResult(int reqCode, int resultCode, Intent data) { super.onActivityResult(reqCode, resultCode, data); switch (reqCode) { case (PICK) : if (resultCode == Activity.RESULT_OK) { Uri contactData = data.getData(); Cursor c = managedQuery(contactData, null, null, null, null); if (c.moveToFirst()) { int indexName = c.getColumnIndex( ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); int indexNumber = c.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER); nom = c.getString(indexName); numero = c.getString(indexNumber); //Visual confirm Toast.makeText(this, "Contact " + nom +" enregistré!", Toast.LENGTH_LONG).show(); //Save in prefs: SharedPreferences manager = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = manager.edit(); editor.putString("num", numero); editor.putString("nom", nom); editor.commit(); </code></pre> <p>The name is correct but the number causes a force close.</p> <p>But if I replace it with the following there is no longer a force close, but the number is still incorrect (0 or 1).</p> <pre><code>int indexNumber = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)+1; </code></pre> <p>What should I do?</p>
    singulars
    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.
 

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