开发者

How to get phone number of an android CDMA phone?

The TelephonyManager.getLine1Number() works on GSM phones, but not CDMA phones. Is 开发者_如何转开发it possible to get the phone number of a CDMA phone through android API calls at all? thanks


Although the method suggested might work, some carriers (I believe it's their choice) do not provide this number, returning null instead.

Returning null is stated in the documentation: http://developer.android.com/reference/android/telephony/TelephonyManager.html (scroll down to the method's documentation).

Here is a link for a possible work-around: http://code.google.com/p/android/issues/detail?id=1110#c5


I've successfully used the following on a Motorola Droid and HTC EVO 4G which are both CDMA.

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = telephonyManager.getLine1Number();

Make sure you are requesting the correct permission in your manifest.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜