thanks a-lot erfan...now it is working fine......
do me a one more favor i need all the number of contact and name too..
but through this code am getting only mobile number..

thanks alot...

On Mon, Aug 2, 2010 at 5:08 PM, Sarwar Erfan <[email protected]> wrote:

>
> Here is your intent:
> intentforcontact= new Intent(Intent.ACTION_PICK,
> ContactsContract.Contacts.CONTENT_URI);
>
>
>
> Here is your result handling:
> //
> =======================================================================
>     @Override
>    protected void onActivityResult(int requestCode, int resultCode,
> Intent data) {
>         super.onActivityResult(requestCode, resultCode, data);
>        switch(requestCode) {
>        case (1) :
>                if (resultCode == Activity.RESULT_OK) {
>                         Uri contactData = data.getData();
>                        String []parts = contactData.toString().split("/");
>                        long id = Long.parseLong(parts[parts.length-1]);
>
>                        Uri rawContactUri =
> ContentUris.withAppendedId(RawContacts.CONTENT_URI, id);
>                         Uri entityUri = Uri.withAppendedPath(rawContactUri,
> Entity.CONTENT_DIRECTORY);
>                         Cursor c = managedQuery(entityUri, new String[]
> {Entity.DATA1},
>                           Entity.MIMETYPE + "=?",
>                          new String[]
> {ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE},
>                           null);
>
>                        try{
>                                c.moveToFirst();
>                                String Number = c.getString(0);
>                        }
>                        catch(Exception ex){
>                        }
>                }
>                break;
>        }
>    }
>
> //===================================================
>
> Beware, it is not mandatory for a contact to have a number :)
> You can add a contact without phone number. It in that case, you will
> end up inside catch(Exception ex){}
>
>
> Regards
> Sarwar Erfan
>
>
> On Aug 2, 4:53 pm, "A N K ! T" <[email protected]> wrote:
> > so tell me how to get number by contactscontract.......am getting name
> and
> > other info but not phone number..please help me
> >
> >
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 

 A N K ! T......

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to