How to get phone number in J2ME?
Asked Answered
F

1

14

How to get the phone number (not contact numbers,etc) in J2ME application ? The phone number that belongs to sim card in the phone.

Filefish answered 2/9, 2011 at 21:41 Comment(0)
G
29

phone number that belongs to sim card in the phone...

above assumption is wrong.

sim card does not store your phone number

SIM card stores only a unique identifier which has nothing to do with your phone number.

The way mobile interacts with network is about as follows:

- [phone] hello network, ID on my SIM is 12345
- [network] hello 12345, I recognized you as a sim card
            currently bound to phone number 987-654-321

If you're interested in details, above is nicely described in this article

If you want to learn more about this unique ID, search the web for term International Mobile Subscriber Identity (IMSI). If you want to access this data from Java ME, you most likely need phone supporting JSR 177 SATSA and you need to understand how APDU works. But that won't help you to get the phone number.

but... why is that?

You mean, why they use some unique identifier instead of phone number? That's easy. Just think of what happens when you loose or break your SIM card, or better yet when someone steals it.

You want new SIM card, but you want your prior number? Fine - you go to the office and they give you new SIM card and bind it to your old number. Now, how it works after that,

- [stolen phone] hello network, ID on my SIM is 12345
- [network] hello 12345, I recognized you as invalid sim card
            so I will ignore you
- [your new phone] hello network, ID on my SIM is 23456
- [network] hello 23456, I recognized you as a sim card
            currently bound to phone number 987-654-321

ok fine but why oh why don't they store both IMSI and phone number?

Because it's much cheaper that way. Think again on the case of lost/broken SIM. What happens? You come to the office, guy at the desk gives you new SIM card and adds a record in database telling that SIM id is now bound to your old phone number. That's simple and cheap.

If they had to store your phone number on SIM card, they would have to somehow record it there and to test if the added record works as expected. That's extra work - and, what would they gain from that? Nothing.

but... but this seems somehow doable with iPhone isn't it?

Not quite so: Programmatically get own phone number in iOS

Groyne answered 3/9, 2011 at 7:30 Comment(5)
WIKI: en.wikipedia.org/wiki/International_Mobile_Subscriber_Identity THE ACTUAL NUMBER TO DIAL: en.wikipedia.org/wiki/MSISDNInebriant
@Inebriant so what? the article you refer states quite clearly "SIM is uniquely associated to an IMSI" there's no phone number on SIM, only IMSI. And can't be for the reasons I provided (case of lost/broken/stolen SIM)Groyne
@Inebriant I see. MSISDN is indeed worth knowing aboutGroyne
I meant but in many telephones you can see your phone number,if the phone see you might be able to see as well sim might have its unique imsi,but after handshake with mobile operator,it might be visible to the phone,like in iphone it is just on the top of contacts visible,of course the iphone translated imsi to phone number and get that value but how to get that value,it is also visible in many nokias as wellFilefish
@Filefish handshake mobile with operator I see. Why not. This would be quite a different question though. And it certainly has nothing to do with "phone number that belongs to sim card in the phone" because as you see, there's just no such thingGroyne

© 2022 - 2024 — McMap. All rights reserved.