Delphi XE5 android得到手机的手机号码


本文整理自网络,侵删。

 首先引用这些:

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;

相关阅读 >>

Delphi路径分割符处理相关函数

Delphi 用idhttp打开网页或下载文件时如何显示进度

Delphi winapi: gettickcount - 获取系统已启动的时间

Delphi yearof 根据指定的日期返回年

Delphi 中文字符串函数问题rightstr

Delphi api 函数: getcursorpos 与转换

Delphi httpresponsestrings

Delphi一个综合实用的单元

Delphi中输入法模式imemode属性的解释

Delphi try abort、exit except 、finally end 执行情况

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...