Answer the question
In order to leave comments, you need to log in
How to find out the phone number on android FMX Delphi?
Hi Giki!))) There is a problem,
var
obj: JObject;
tm: JTelephonyManager;
identifier: String;
begin
obj := SharedActivityContext.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE);
if obj <> nil then
begin
tm := TJTelephonyManager.Wrap( (obj as ILocalObject).GetObjectID );
if tm <> nil then
identifier := JStringToString(tm.getDeviceId);
end;
if identifier = '' then
identifier := JStringToString(TJSettings_Secure.JavaClass.getString(SharedActivity.getContentResolver,
TJSettings_Secure.JavaClass.ANDROID_ID));
showmessage(identifier);
var
tMgr: JTelephonyManager;
PhoneNumber: String;
begin
tMgr := TJTelephonyManager.Wrap((SharedActivityContext.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE)
as ILocalObject).GetObjectID);
PhoneNumber := JStringToString(tMgr.getLine1Number);
Label1.Text:=PhoneNumber;
the output of the phone number does not want to ... it gives an empty line in response. what could be the trouble and is there an alternative to find out the phone number?
Answer the question
In order to leave comments, you need to log in
Hello.
Your question says a lot about your IT qualifications. I have known since 8-9 of that class that the mobile number is NOT stored in the mobile ... And not what function, the procedure is not able to recognize it ....
It is SIMPLY not in the phone ...
This function that you copied ... It shows the number that was entered in the SIM card settings either by the user or the operator, if it is not entered, then of course the function returns an empty result ...
You do not know how to think correctly and thus ask questions ... (Learn this first, then move on to programming). Before this question "How to find out the phone number on Android FMX Delphi?" Carry out an elementary analysis, read about the SIM card and what information it stores in itself, whether it contains a mobile number and for which country .... You didn’t do anything and ask questions here that, frankly speaking, you don’t want to answer. ... Understand a simple thing ...
You are trying to write a program, and the program runs on the OS and the OS is on the device.
You must first know basic things about the device, then about the OS, and then move on to programming .... And you don't even know where the Mob number is stored ....
Here's a screenshot of my phone ...
This algorithm also returned an empty result for me, since my SIM card also does not contain my MOB number ... But he showed the IMEI code, and indeed it is in any phone, why not show it ???
Here is a link to the Japanese site. It shows what can be learned from the SIM card. (Maximum).
delphi
xe6
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question