Is it possible to get own phone number?

StuartM

Member
Licensed User
Longtime User
A search suggests that, subject to SIM security, this is possible in Java via:

B4X:
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
  mPhoneNumber = tMgr.getLine1Number();

But is this possible in B4A?

It doesn't matter if it is unreliable, it would just be a "default" to avoid some app users having to type their own number into an app set-up screen.

(Obligatory, sorry 1st post apology goes here :) Got the trial last night and bought today so still learning.)
 

bsnqt

Active Member
Licensed User
Longtime User
Well, if the phone number is not "physically" existing in the user's SIM card or being stored somewhere else in the phone, I don't really see the difference between using or not using Reflection call... The issue is that, whatever method you are using, the number should be there to be retrieved. Once it is there, we can use getLine1Number() without need of using Reflection (or maybe you mentioned about other ways that I don't know)

Or may be I don't really well understand your question, sorry :)
 
Last edited:
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
I had the same problem on 1 phone and 1 tablet, so I tested the "small offering" from tremara1, but it didn't work.
I changed a few little things.
I compiled it again and so you can use it for testing, if your SIM shows the phone number ... ;)
 

Attachments

  • PhoneNumberTest.zip
    27.8 KB · Views: 473
Upvote 0
Top