Android realizes the function of obtaining contact phone number

This document mainly records a way to obtain the contact's telephone number.

1. Select contact

2. Process selection results

3. Request runtime permissions

After Android 6.0, read_ Contacts becomes a runtime permission. Therefore, in addition to declaring permissions in androidmanifest.xml (compatible with lower versions), you also need to actively apply in the code.

4. Processing permission application results

Here's something to note:

1) . if the fragment in the compatibility library is not used, onrequestpermissionsresult must be defined in the activity containing the fragment to ensure that it can be called.

2) . if the user clicks the button "refuse permission application and no longer prompt", the result of applying for permission again will always be denied. At this time, you must enter the application management in settings and enable the runtime permission.

5. Check the phone number and dial

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>