Bon dia,
Necessito accedir als contactes del dispositiu, concretament al nom, telefon i email si n'hi ha. Faig servir la URI Phone.CONTENT_URI i d'aquí trec d'un contacte concret
el Nom i el telèfon, però no el email. Crec que la culpa és de la URI, n'he de fer servir un altre? O dues alhora? per accedir a diferent informació en diferents URI's?
Sabeu quina és la millor manera de fer-ho?
Merci,
Ara el meu codi està així:
/*CONDICIONS*/
String[] mProjection = new String[]
{
Phone.DISPLAY_NAME,
Phone.NUMBER
};
String selection = Phone.DISPLAY_NAME + " LIKE '" + sUser + "'";
// Retrieves the profile from the Contacts Provider
Cursor mProfileCursor =
getContentResolver().query(
Phone.CONTENT_URI,
mProjection ,
selection,
null,
null);
.....
/*i després això per accedir a la INFO */
if (mProfileCursor.moveToFirst()) {
String calName, numTel;
int numc = mProfileCursor.getCount();
int l_nameCol = mProfileCursor.getColumnIndex(mProjection[0]);
int l_numTel = mProfileCursor.getColumnIndex(mProjection[1]);
do {
calName = mProfileCursor.getString(l_nameCol);
numTel = mProfileCursor.getString(l_numTel);
if (calName.equals(sUser)) {
txtNomContacte.setText("Nom = " + calName);
txtTelefon.setText(numTel);
}
}while (mProfileCursor.moveToNext());
}else {
txtNomContacte.setText("No hi ha contactes");
}