संपर्क सभी संपर्कों दिखा पिकर कॉलिंग पढ़ने से संपर्क उठा इस linke किया जाता है (यहाँ इतने पर कई बार कहा गया है):समस्याएं फोन नंबर के साथ और फोन नंबर
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
startActivityForResult(intent, REQ_CODE);
मैं संपर्क हो रही है नाम और निम्नलिखित स्निपेट के साथ onActivityResult में सभी अपने फोन नंबर:
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
Uri contactUri = intent.getData();
ContentResolver resolver = getContentResolver();
long contactId = -1;
// get display name from the contact
Cursor cursor = resolver.query(contactUri,
new String[] { Contacts._ID, Contacts.DISPLAY_NAME },
null, null, null);
if(cursor.moveToFirst())
{
contactId = cursor.getLong(0);
Log.i("tag", "ContactID = " + Long.toString(contactId));
Log.i("tag", "DisplayName = " + cursor.getString(1));
}
// get all phone numbers with type from the contact
cursor = resolver.query(Phone.CONTENT_URI,
new String[] { Phone.TYPE, Phone.NUMBER },
Phone.CONTACT_ID + "=" + contactId, null, null);
while(cursor.moveToNext())
{
Log.i("tag", "PhoneNumber = T:" + Integer.toString(cursor.getInt(0)) + "/N:" + cursor.getString(1));
}
एक फोन नंबर के साथ संपर्क पिकर और केवल शो संपर्क कॉलिंग इस तरह किया जा सकता है (यह भी इतने पर पाया जाता है):
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, REQ_CODE);
अगर मैं ऐसा करते हैं, मैं केवल संपर्क पिकर में उन संपर्कों कि कम से कम एक फोन नंबर है, जो वास्तव में मैं क्या जरूरत है की क्या ज़रूरत है देखते हैं। दुर्भाग्यवश, उपरोक्त कोड स्निपेट के साथ मुझे केवल प्रदर्शन नाम मिलता है लेकिन अब कोई फ़ोन नंबर नहीं है।
किसी को भी एक विचार है कि मैं क्या फोन नंबर प्राप्त करने के लिए बदलने के लिए है? इस तरह Phone._ID के लिए जहां clausule में अग्रिम Phone.Contact_Id में
आपके उत्तर Jordi के लिए धन्यवाद। वास्तविक समस्या यह है कि, मेरे प्रश्न की एक्टिविटी रीसेट विधि में पहली क्वेरी:। यह 'intent.setType (..)' के साथ इरादे में टाइप सेट करता है या नहीं, इस पर निर्भर करता है कि यह संपर्क या फोन की आईडी देता है। और चूंकि मुझे संपर्क पढ़ने के लिए दोनों तरीकों की आवश्यकता है (फ़ोन फ़िल्टर के साथ या संपर्क के साथ संपर्क पिकर का उपयोग करके), मुझे इसके आधार पर पहली क्वेरी में Contact._ID और DisplayName को पढ़ना होगा। लेकिन आपका उत्तर मदद ... फिर से धन्यवाद। – infero