如何在 Android 中获取自己的电话号码
我正在尝试开发一个应用程序,每次在手机中插入新的 SIM 卡时都需要 SIM 卡的电话号码......然后我将使用该电话号码让用户订阅在线服务器。我已阅读很多论坛都发现了类似的东西,
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();
但每个人都说这不是一个有效的方法。如果这不是一个有效的方法,那么哪个是有效的方法,而且我不能使用任何其他属性,如 SIM ID 或订阅者 ID 等。我只需要电话号码。任何帮助将不胜感激。
I am trying to develop an application that needs the phone number of SIM Card every time a new SIM Card is inserted in the phone....Then i will use that phone number to get the user subscribed to an online server.I have read many forums and found something like this
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();
but everyone said that this is not an efficient method.If this is not an efficient method then which is the efficient method and also I cannot use any other property like SIM id or Subscriber ID etc.I only need the PHONE NUMBER. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,此方法并不总是返回正确的 SIM 号码;这取决于SIM卡本身。
如果您确实想获取 SIM 卡号码,您可以向特定手机发送短信,这样您就可以获得它。
As far as I know, this method would not always return right SIM number; it depends on the SIM card itself.
If you really want to get the SIM number, you can send a SMS to a specific phone, so you will get it.