标签:其他 star graphics ber 打电话 upd getline shared manager
//获取手机信息 function GetPhoneInfo(): string; Var TelephonyManager: JTelephonyManager; TelephonyServiceNative: JObject; begin result := ‘‘; TelephonyServiceNative := SharedActivityContext.getSystemService (TJContext.JavaClass.TELEPHONY_SERVICE); if Assigned(TelephonyServiceNative) then TelephonyManager := TJTelephonyManager.Wrap ((TelephonyServiceNative as ILocalObject).GetObjectID); result := JStringToString(TelephonyManager.getLine1Number);//取得手机号 //TelephonyManager.getDeviceId 取IMEI //TelephonyManager.getLine1Number 取MSISDN 手机号,大部分SIM卡中不会写入这个信息 //TelephonyManager.getSimSerialNumber 取ICCID //TelephonyManager.getSubscriberId 取IMSI 运营商实际上是用这个查询的 end; //手机振动 uses FMX.Helpers.Android, Androidapi.JNI.App, Androidapi.JNI.Os, Androidapi.JNIBridge, FMX.StdCtrls; procedure TForm1.Button2Click(Sender: TObject); function GetVibratorArray(const AintArr:array of int64):TJavaArray<int64>;//震动规律函数 var Lindex:integer; begin Result:=TJavaArray<int64>.Create(Length(AintArr)); for Lindex:=Low(AintArr) to High(AintArr) do Result.Items [Lindex]:= AintArr[Lindex]; end; var LVibrator:JVibrator; LJavaArray:TJavaArray<int64>; begin LVibrator:=TJVibrator.Wrap((SharedActivity.getSystemService(TJActivity.javaClass.VIBRATOR_SERVICE ) as iLocalObject).GetObjectID );//引用震动 if not LVibrator.hasVibrator then begin showmessage(‘手机不支持震动‘); exit; end; LVibrator.vibrate(200);//震动200ms LVibrator.cancel ;//立刻停止震动 LJavaArray:=GetVibratorArray([200,1000,3000,5000]);//调用震动规律 LVibrator.vibrate(LJavaArray,-1);//不重复, 震动一 次 LJavaArray:=GetVibratorArray([200,1000,3000,5000]);//调用震动规律 LVibrator.vibrate(LJavaArray,0);//v不停重复,大于0的参数,可以指定震动次数 end;
//剪贴版FClipboardService: IFMXClipboardService; TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, IInterface(FClipboardService)); FClipboardService.SetClipboard(Tvalue(Edit1.Text)); //复制 FClipboardService.GetClipboard.ToString; //粘贴 //键盘FService: IFMXVirtualKeyboardToolbarService; if TPlatformServices.Current.SupportsPlatformService (IFMXVirtualKeyboardToolbarService, IInterface(FService)) then begin FService.SetToolbarEnabled(true); FService.SetHideKeyboardButtonVisibility(true); end;
//电话信息(Call拨号) PhoneDialerService: IFMXPhoneDialerService; //获取电话服务信息 procedure TPhoneDialerForm.btnGetCarrierInfoClick(Sender: TObject); var PhoneDialerService: IFMXPhoneDialerService; begin { test whether the PhoneDialer services are supported } if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then begin { if yes, then update the labels with the retrieved information } CarrierNameItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetCarrierName; CountryCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetIsoCountryCode; NetworkCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileCountryCode; MobileNetworkItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileNetwork; end else ShowMessage(‘PhoneDialer service not supported‘); end; //拨号 procedure TPhoneDialerForm.btnMakeCallClick(Sender: TObject); var PhoneDialerService: IFMXPhoneDialerService; begin { test whether the PhoneDialer services are supported } if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then begin { if the Telephone Number is entered in the edit box then make the call, else display an error message } if edtTelephoneNumber.Text <> ‘‘ then PhoneDialerService.Call(edtTelephoneNumber.Text) else begin ShowMessage(‘Please type in a telephone number.‘); edtTelephoneNumber.SetFocus; end; end else ShowMessage(‘PhoneDialer service not supported‘); end; Intent :TJIntent uses Androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android, Androidapi.JNI.Net, Androidapi.Helpers; procedureCall_URI(constAAction : JString;constAURI: string); var uri: Jnet_Uri; Intent: JIntent; begin uri := StrToJURI(AURI); Intent := TJIntent.JavaClass.init(AAction, uri); {Intent.putExtra() //短信 Call_URI(TJIntent.JavaClass.ACTION_SENDTO, ‘smsto:137114553XX‘); Intent.putExtra(StringToJString(‘sms_body‘), StringToJString(‘测试短信‘)); 如果是要发短信等复杂的应用,需要传递各种其他的参数.要用到Intent.putExtra()传递多个参数. 这里只封装最简单的,具体Intent.putExtra()的用法,可以查询Java的资料.大把的 } SharedActivityContext.startActivity(Intent); end; //使用例子: //打电话 Call_URI(TJIntent.JavaClass.ACTION_CALL, ‘tel:137114553XX‘); //打开地图显示某个坐标点 Call_URI(TJIntent.JavaClass.ACTION_VIEW, ‘geo:38.899533,-77.036476‘); //打开网页 Call_URI(TJIntent.JavaClass.ACTION_VIEW, ‘www.baidu.com‘); //发送电子邮件 Call_URI(TJIntent.JavaClass.ACTION_SENDTO, ‘mailto:wr960204@126.com‘); //播放音乐 Call_URI(TJIntent.JavaClass.ACTION_VIEW, ‘file:///sdcard/download/最炫民族风.mp3‘);
delphi xe10 手机内部系统相关操作(手机信息、震动、剪贴板、键盘、电话、拨号)
标签:其他 star graphics ber 打电话 upd getline shared manager
原文地址:https://www.cnblogs.com/guorongtao/p/11137361.html