1

我正在尝试开发一个应用程序,每次将新 SIM 卡插入手机时都需要 SIM 卡的电话号码....然后我将使用该电话号码让用户订阅在线服务器。我已阅读很多论坛,发现了这样的东西

TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);

mPhoneNumber = tMgr.getLine1Number();

但是每个人都说这不是一种有效的方法。如果这不是一种有效的方法,那么这是一种有效的方法,而且我不能使用任何其他属性,如 SIM id 或 Subscriber ID 等。我只需要电话号码。任何帮助,将不胜感激。

4

2 回答 2

0

TelephonyManager is not the right Solution,Because in some cases the number is not stored in the SIM, Due to my suggestion,You should use Shared Preference to store user's Phone number first time the application is open, and after that the number will used whenever you need in application. Thank you.

于 2014-01-09T12:28:47.217 回答
0

据我所知,这种方法并不总是返回正确的 SIM 号码;这取决于 SIM 卡本身。如果你真的想得到 SIM 号码,你可以向特定的手机发送一条短信,这样你就会得到它。

于 2011-07-21T11:04:44.090 回答