首先要uses
[pascal]
uses
FMX.Platform.Android,
Androidapi.JNI.Telephony,
Androidapi.JNI.Provider ,
Androidapi.JNIBridge,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes,
FMX.Helpers.Android;
[/pascal]
接著放上Button,在Click事件打上
[pascal]
var
obj: JObject;
tm: JTelephonyManager;
IMEI: 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
IMEI := JStringToString(tm.getDeviceId);
end;
if IMEI = ” then
IMEI := JStringToString(TJSettings_Secure.JavaClass.getString( SharedActivity.getContentResolver, TJSettings_Secure.JavaClass.ANDROID_ID));
ShowMessage(‘IMEI :’ + #13 + IMEI);
[/pascal]