how to fetch android phone conatacts of a persion like home phone numer, work phone number, home email, work email and put it in the edittext? -
the following code, showing persons phone number type radio button selection,but not showing emails, need select email also` public void getcontacts() { log.i(classtag, "contactsbutton on click"); intent intent = new intent(intent.action_get_content); intent.settype(contactscontract.commondatakinds.phone.content_item_type);
startactivityforresult(intent, 1); // log.i(classtag, "contactintent:"+contactpickerintent); } protected void onactivityresult(int requestcode, int resultcode, intent data) { if (data != null) { uri uri = data.getdata(); if (uri != null) { cursor c = null; cursor e=null; try { c = getcontentresolver().query(uri, new string[]{ contactscontract.commondatakinds.phone.number, contactscontract.commondatakinds.phone.type ,contactscontract.commondatakinds.email.data,contactscontract.commondatakinds.email.type}, null, null, null); string number=null; int type=0; string email=null; string emailtype=null; if (c != null && c.movetofirst()) { number = c.getstring(0); as=number; type = c.getint(1); email=c.getstring(2); emailtype=c.getstring(3); log.i(classtag, "type is:"+type); log.i(classtag, "email is:"+email); log.i(classtag, "emailtype is:"+emailtype); // showselectednumber(type, number); telephonymanager tmgr =(telephonymanager)getapplicationcontext().getsystemservice(context.telephony_service); string iso=tmgr.getnetworkcountryiso(); log.i("device iso", "=======>"+iso); string mbno=tmgr.getline1number(); log.i("mbno", "=======>"+mbno); phonenumberformat(number); intent i=new intent(contact.this, tab.class); i.putextra("key", number); contact.this.startactivityforresult(i, 0); } cursor emails = getcontentresolver().query(contactscontract.commondatakinds.email.content_uri,null,contactscontract.commondatakinds.email.contact_id + " = " + type,null, null); log.i(classtag, "emai:"+emails); string emailaddress=null; while (emails.movetonext()) { emailaddress = emails.getstring(emails.getcolumnindex(contactscontract.commondatakinds.email.data)); log.i(classtag, "email is:"+emailaddress); } // as=emailaddress; } { if (c != null) { c.close(); } } } } }
Comments
Post a Comment