Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the first name (or full name) of the user of the phone?

Tags:

android

Is there a way to get the user's first name or entire name? I mean the user of the phone

does it require special manifest permissions?

like image 282
ycomp Avatar asked Feb 17 '12 05:02

ycomp


3 Answers

Yep, starting in ICS you can read the profile of the device owner (which requires the READ_PROFILE permission):

http://developer.android.com/reference/android/provider/ContactsContract.Profile.html

Specifically the DISPLAY_NAME column should have their name. Or you could look up the StructuredName data item to get their GIVEN_NAME:

http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredName.html

like image 63
Jeff Sharkey Avatar answered Oct 07 '22 05:10

Jeff Sharkey


What exactly do you mean? You may be able to access the name in certain ways:

  1. You can try to access their information stored in a Google account, requiring the GET_ACCOUNTS permission
  2. You could, as Vinayak.B suggested, try to glean the info from the contacts, requiring the READ_CONTACTS and the READ_PHONE_STATE permission, although I think this is a hit-or-miss option.
  3. There is also a READ_PROFILE permission, which I think is an interesting way to go, but I don't have any experience with that, so I can't tell you whether or not it's a fruitful venture.

I would try the GET_ACCOUNTS option first, since they must have a Google account to download your app. It also seems a little less invasive to me

I really hope this answers your question, but if it doesn't, you really need to provide more information.

like image 21
gobernador Avatar answered Oct 07 '22 05:10

gobernador


Do you mean from device Contact list? if yes, get the source code and which permission from here : http://tutorials-android.blogspot.in/2011/11/how-to-call-android-contacts-list.html

like image 42
Vinayak Bevinakatti Avatar answered Oct 07 '22 04:10

Vinayak Bevinakatti