如何获取真实设备中当前SIM卡的手机号码?
我必须提交一份申请,显示小区中使用的 SIM 卡的联系号码。为此,我需要使用 TelephonyManager
类。我可以获得其使用的详细信息吗?
I have to make an application which shows the contact no of the SIM card that is being used in the cell. For that I need to use TelephonyManager
class. Can I get details on its usage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用 TelephonyManager 来执行此操作:
getLine1Number()<的文档/code>
表示如果号码“不可用”,此方法将返回
null
,但它没有说明该号码何时可能不可用。您需要授予应用程序 进行此查询的权限 通过将以下内容添加到清单中:(
您不应使用
TelephonyManager.getDefault()
来获取TelephonyManager
作为 这是一个未记录的私有 API 调用,将来可能会更改。)You can use the
TelephonyManager
to do this:The documentation for
getLine1Number()
says this method will returnnull
if the number is "unavailable", but it does not say when the number might be unavailable.You'll need to give your application permission to make this query by adding the following to your Manifest:
(You shouldn't use
TelephonyManager.getDefault()
to get theTelephonyManager
as that is a private undocumented API call and may change in future.)嗨,实际上这是我同样的问题,但我没有得到任何信息。现在我从特定的 Android 真实设备(Android 手机)获得了手机号码和他的电子邮件 ID。现在 90% 的人在 Android 手机上使用什么应用程序。并且现在我通过 What's app API 获取手机号码和电子邮件 ID。使用起来非常简单,请参阅下面的代码。
并导入这个API
Hi Actually this is my same question but I didn't get anything.Now I got mobile number and his email-Id from particular Android real device(Android Mobile).Now a days 90% people using what's App application on Android Mobile.And now I am getting Mobile no and email-ID Through this What's app API.Its very simple to use see this below code.
and import this API
我必须制作一个应用程序,显示小区中使用的 SIM 卡的联系号码。为此,我需要使用电话管理器类。我可以获得其使用的详细信息吗?
是的,
您必须使用电话管理器;如果您根本找不到联系号码。用户的;
您可以使用相同的 Telephony Manager 类获取 Sim 卡的 Sim 序列号和 Android 设备的 Imei 号码...
添加权限:
导入:
使用以下代码:
I have to make an application which shows the Contact no of the SIM card that is being used in the cell. For that I need to use Telephony Manager class. Can i get details on its usage?
Yes,
You have to use Telephony Manager;If at all you not found the contact no. of user;
You can get Sim Serial Number of Sim Card and Imei No. of Android Device by using the same Telephony Manager Class...
Add permission:
Import:
Use the below code:
好吧,所有这些都可能是临时黑客,但没有办法获取用户的手机号码。这是违反道德政策的。
例如,上面的答案之一建议获取所有帐户并从那里提取。而且它不再起作用了!
所有这些都只是黑客行为。
获取用户手机号码的唯一方法是通过运营商。如果您与 Aitel、Vodafone 等移动运营商有合作,当通过移动网络互联网连接时,您可以在移动手机的请求标头中获取用户的手机号码。
不确定是否有任何制造商联手获得特定许可可以提供帮助 - 没有探索这个领域,但至少没有任何记录。
Well, all could be temporary hacks, but there is no way to get mobile number of a user. It is against ethical policy.
For eg, one of the answers above suggests getting all accounts and extracting from there. And it doesn't work anymore!
All of these are hacks only.
Only way to get user's mobile number is going through operator. If you have a tie-up with mobile operators like Aitel, Vodafone, etc, you can get user's mobile number in header of request from mobile handset when connected via mobile network internet.
Not sure if any manufacturer tie ups to get specific permissions can help - not explored this area, but nothing documented atleast.
有时,您可以通过向运营商发出 USSD 请求来检索电话号码。
例如我可以通过拨打 *116# 获取我的电话号码
我想,如果可以以某种方式捕获 USSD 响应,这可能可以在应用程序内完成。
当然,这不是我建议在要分发的应用程序中使用的方法,代码甚至可能在运营商之间有所不同。
Sometimes you can retreive the phonenumber with a USSD request to your operator.
For example I can get my phonenumber by dialing *116#
This can probably be done within an app, I guess, if the USSD responce somehow could be catched.
Offcourse this is not a method I would recommend to use within an app that is to be distributed, the code may even differ between operators.
正如许多人所说:
可用性严格取决于运营商以及 SIM 卡上的号码编码方式。如果它是由制造 SIM 卡的公司或移动运营商本身进行硬编码的。这与“设置”->“关于手机”中的返回内容相同。
As many said:
The availability depends strictly on the carrier and the way the number is encoded on the SIM card. If it is hardcoded by the company that makes the SIMs or by the mobile carrier itself. This returns the same as in Settings->about phone.