Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get phone number in J2ME?

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

like image 247
user818117 Avatar asked Sep 02 '11 21:09

user818117


1 Answers

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

like image 95
gnat Avatar answered Oct 29 '22 17:10

gnat