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?
是否需要特殊的manifest权限?
3 个解决方案
#1
17
Yep, starting in ICS you can read the profile of the device owner (which requires the READ_PROFILE permission):
是的,从ICS开始,您可以读取设备所有者的配置文件(需要READ_PROFILE权限):
http://developer.android.com/reference/android/provider/ContactsContract.Profile.html
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:
具体地说,DISPLAY_NAME列应该有它们的名称。或者您可以查找结构化名称数据项,以获得它们的GIVEN_NAME:
http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredName.html
#2
7
What exactly do you mean? You may be able to access the name in certain ways:
你到底是什么意思?你可以用某些方式访问这个名字:
- You can try to access their information stored in a Google account, requiring the
GET_ACCOUNTS
permission - 您可以尝试访问存储在谷歌帐户中的信息,这需要GET_ACCOUNTS权限
- You could, as Vinayak.B suggested, try to glean the info from the contacts, requiring the
READ_CONTACTS
and theREAD_PHONE_STATE
permission, although I think this is a hit-or-miss option. - 你可以,如Vinayak。B建议,尝试从联系人中收集信息,需要READ_CONTACTS和READ_PHONE_STATE权限,尽管我认为这是一个“点击-忽略”选项。
- 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. - 还有一个READ_PROFILE权限,我认为这是一种有趣的方式,但我对此没有任何经验,所以我不能告诉您这是否是一个富有成效的尝试。
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
我想先试试GET_ACCOUNTS选项,因为他们必须有一个谷歌帐户才能下载您的应用程序。对我来说,它的入侵性也要小一些
I really hope this answers your question, but if it doesn't, you really need to provide more information.
我真的希望这能回答你的问题,但如果没有,你真的需要提供更多的信息。
#3
2
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
你是指设备联系人列表吗?如果有,请从这里获取源代码和哪个权限:http://tutorials-android.blogspot.in/2011/11/howto -call-android-contacts-list.html
#1
17
Yep, starting in ICS you can read the profile of the device owner (which requires the READ_PROFILE permission):
是的,从ICS开始,您可以读取设备所有者的配置文件(需要READ_PROFILE权限):
http://developer.android.com/reference/android/provider/ContactsContract.Profile.html
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:
具体地说,DISPLAY_NAME列应该有它们的名称。或者您可以查找结构化名称数据项,以获得它们的GIVEN_NAME:
http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredName.html
#2
7
What exactly do you mean? You may be able to access the name in certain ways:
你到底是什么意思?你可以用某些方式访问这个名字:
- You can try to access their information stored in a Google account, requiring the
GET_ACCOUNTS
permission - 您可以尝试访问存储在谷歌帐户中的信息,这需要GET_ACCOUNTS权限
- You could, as Vinayak.B suggested, try to glean the info from the contacts, requiring the
READ_CONTACTS
and theREAD_PHONE_STATE
permission, although I think this is a hit-or-miss option. - 你可以,如Vinayak。B建议,尝试从联系人中收集信息,需要READ_CONTACTS和READ_PHONE_STATE权限,尽管我认为这是一个“点击-忽略”选项。
- 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. - 还有一个READ_PROFILE权限,我认为这是一种有趣的方式,但我对此没有任何经验,所以我不能告诉您这是否是一个富有成效的尝试。
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
我想先试试GET_ACCOUNTS选项,因为他们必须有一个谷歌帐户才能下载您的应用程序。对我来说,它的入侵性也要小一些
I really hope this answers your question, but if it doesn't, you really need to provide more information.
我真的希望这能回答你的问题,但如果没有,你真的需要提供更多的信息。
#3
2
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
你是指设备联系人列表吗?如果有,请从这里获取源代码和哪个权限:http://tutorials-android.blogspot.in/2011/11/howto -call-android-contacts-list.html