The getLine1Number() method in TelephonyManager retrieves the data in
the "phone number" stored on the SIM card (NOT the phone number bound
to the user's account) - this is often either wrong or non-existent,
depending on the network provider it was shipped from.

For example, UK Vodafone appear to never populate this field on their
SIM cards (someone might prove me wrong here, but I've had a lot of
user feedback from my "What's My Number?" app confirming this).

Also, people who transfer their numbers will still have the old number
that was originally shipped with their SIM card stored in that field,
it is never updated.

The only solution I can offer you is to ask the user for their phone
number, and provide the number in the SIM card as a default value if
it is available. Never expect the number to be present or correct
though. If you find a better solution I would be very interested to
hear it, but I don't think that solution will come from the SIM card.

Check out the source code for my app if you want to see how this can
be done for an appwidget:
http://github.com/seanhodges/Whats-My-Number. It's also available on
the Android Market:
http://www.cyrket.com/p/android/mynumberwidget.app/



On Thu, Mar 25, 2010 at 9:25 AM, a a <harvey.a...@gmail.com> wrote:
> I know there have a getLine1Number(),
>
>  i have inserted the SIM card, but why it return null?.
>
> 2010/3/25 a a <harvey.a...@gmail.com>:
>> Dear android,
>>
>> How can i get the SIM card number?
>>
>> i use below:
>>       TelephonyManager telMgr =
>> (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
>>        String sim = telMgr.getSimSerialNumber();
>> it return 89860109300212882323, this is a serial number for SIM card,
>> but i wan't the mobile number
>> (it is storaged in the SIM card, is it rigth???  how get it?
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
> To unsubscribe from this group, send email to 
> android-developers+unsubscribegooglegroups.com or reply to this email with 
> the words "REMOVE ME" as the subject.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to