[Android] obtains the phone number of the local machine.

Source: Internet
Author: User

Android provides an API to get the SIM card number, that is, to get the phone number of the local machine through telephonmanager.

It is particularly mentioned that information on the Internet shows that the new version of the dynamic zone card cannot be obtained. Is it unclear whether it is true? My card can be obtained, thank you! The remedy is to send an email to 10086 (10010) and then get the email from the sender ......

PS: Some developers cannot read the phone number. I will explain it to you below. The reason is that the operator did not input data to the corresponding API in the phone card. The previous cards were all input, and new cards were not input. Why? I guess it may be to save costs ......

MethodCode:

Telephonymanager telephonmanager = (telephonymanager) getsystemservice (context. telephony_service); string telephonenumber = telephonmanager. getline1number ();

Permissions in manifest:

<Uses-Permission Android: Name = "android. Permission. read_phone_state"/>

Engineering Resources: http://download.csdn.net/detail/etzmico/3975400

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.