首先引用这些:
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls
,Androidapi.JNI.GraphicsContentViewText, Androidapi.JNIBridge,
Androidapi.JNI.Telephony, Androidapi.JNI.JavaTypes, FMX.Helpers.Android,
FMX.Edit;
具体代码:
procedure TForm1.Button1Click(Sender: TObject);
var
TelephonyManager: JTelephonyManager;
TelephonyServiceNative: JObject;
begin
TelephonyServiceNative := SharedActivityContext.getSystemService
(TJContext.JavaClass.TELEPHONY_SERVICE);
if Assigned(TelephonyServiceNative) then
TelephonyManager := TJTelephonyManager.Wrap
((TelephonyServiceNative as ILocalObject).GetObjectID);
showmessage(JStringToString(TelephonyManager.getDeviceId));// 取IMEI
showmessage(JStringToString(TelephonyManager.getLine1Number)) ;// 取MSISDN 手机号,大部分SIM卡中不会写入这个信息
showmessage(JStringToString(TelephonyManager.getSimSerialNumber));// 取ICCID
showmessage(JStringToString(TelephonyManager.getSubscriberId));// 取IMSI 运营商实际上是用这个查询的他那张对应电话号码的表
//还有很多方法,具体请查看JTelephonyManager的声明
end;
关键字词: