gpt4 book ai didi

android - 如何在 Android 设备上获取用户配置文件

转载 作者:太空狗 更新时间:2023-10-29 16:43:52 28 4
gpt4 key购买 nike

我希望能够自动将信息输入到创建帐户表单中,并根据用户已经输入到设备中的信息(例如他们的姓名、电子邮件地址、电话号码)建议可能性。我需要一种与回到 API 级别 8 兼容的方法。

最佳答案

我找到了 Roman Nurik's answer到一个非常相似的答案,因此我的答案是基于他的答案。这是 gist of my answer .您需要向 AndroidManifest.xml 添加权限和功能才能访问用户的个人资料:

<!-- Allows application to view phone state like using readLine1Number() -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!-- Required to access the Contacts Provider and user profile -->
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>

<!-- Allows the application to use telephony to get the devices phone number when telephony is available without requiring telephony -->
<uses-feature android:name="android.hardware.telephony" android:required="false"/>

该方法使用 Roman 根据设备支持的 API 级别描述的两种方法之一。它显示了如何利用用户设置的主要字段以及何时设置多个值。它使用 TelephonyManager 检索设备的电话号码。

关于android - 如何在 Android 设备上获取用户配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13350844/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com