delphixe 10 android操作は電話、カメラ、位置付けなどをします。

72785 ワード


 
XE6    JStringToString、StringTojString、StrToJURI:use Androidapi.Helpers


//Splash Image Delphi XE5,XE6,XE7 Android , Java Activity Splash , Delphi XE7 Splash Image 。 : 1. , Options, 2. Application 3. Include Splash Image 4. Splash Image 5. Splash Tile mode Splash Gravity Splash Tile Mode disabled - , Splash Gravity clamp - repeat - , Splash Image mirror - repeat , 。 Gravity , Splash Title Mode Disable , , 。 project ->deployment-> , sqlite test.s3db, remote path assets\internal\ ( ) project ->Option->Version Info->label FMX.Consts ( )   { Dialog Strings } //  SMsgDlgWarning = 'Warning'; //  SMsgDlgError = 'Error'; //  SMsgDlgInformation = 'Information'; //  SMsgDlgConfirm = 'Confirm'; //  SMsgDlgYes = 'Yes'; //  SMsgDlgNo = 'No'; //  SMsgDlgOK = 'OK'; //  SMsgDlgCancel = 'Cancel'; //  SMsgDlgHelp = 'Help'; //  SMsgDlgHelpNone = 'No help available'; //  SMsgDlgHelpHelp = 'Help'; //  SMsgDlgAbort = 'Abort'; //  SMsgDlgRetry = 'Retry'; //  SMsgDlgIgnore = 'Ignore'; //  SMsgDlgAll = 'All'; //  SMsgDlgNoToAll = 'No to All'; //  SMsgDlgYesToAll = 'Yes to &All'; //  SMsgDlgClose = 'Close'; // //  SWindowsVistaRequired = '%s requires Windows Vista or later'; // //  SUsername = '&Username'; //  SPassword = '&Password'; //  SDomain = '&Domain'; //  SLogin = 'Login';   SMsgDlgWarning = ' ';   SMsgDlgError = ' ';   SMsgDlgInformation = ' ';   SMsgDlgConfirm = ' ';   SMsgDlgYes = ' ';   SMsgDlgNo = ' ';   SMsgDlgOK = ' ';   SMsgDlgCancel = ' ';   SMsgDlgHelp = ' ';   SMsgDlgHelpNone = ' ';   SMsgDlgHelpHelp = ' ';   SMsgDlgAbort = ' ';   SMsgDlgRetry = ' ';   SMsgDlgIgnore = ' ';   SMsgDlgAll = ' ';   SMsgDlgNoToAll = ' “ ”';   SMsgDlgYesToAll = ' “ ”'; SMsgDlgClose = ' '; SWindowsVistaRequired = '%s Windows Vista ';   SUsername = '& ';   SPassword = '& ';   SDomain = '& ';   SLogin = ' '; ( 、IOS) function GeFileName(const AFileName: string): string; begin {$IFDEF ANDROID}   Result := TPath.GetTempPath + '/' + AFileName; {$ELSE}   {$IFDEF IOS}     Result := TPath.GetHomePath + '/Documents/' + AFileName;   {$ELSE}     Result := AFileName;   {$ENDIF} {$ENDIF} end; IOUtils TPath.GetTempPath; { }  TPath.GetTempFileName; { } TPath.GetPathRoot(); { , : c:\} TPath.GetDirectoryName(); { } TPath.GetFileName(); { } TPath.GetExtension(); { } TPath.GetFileNameWithoutExtension(); { } TPath.ChangeExtension(); { } TPath.DriveExists(); { } TPath.GetFullPath(); { } TPath.HasExtension(); { } TPath.IsPathRooted(); { } TPath.Combine(); { } TPath.GetRandomFileName; { } TPath.GetGUIDFileName(); { , -}  TPath.IsValidPathChar(); { } TPath.IsValidFileNameChar(); { } TPath.AltDirectorySeparatorChar; {Windows "\"} TPath.AltDirectorySeparatorChar; {Windows "/"} TPath.ExtensionSeparatorChar; {Windows "."} TPath.PathSeparator; {Windows ";"} TPath.VolumeSeparatorChar; {Windows ":"} // TDirectory.CreateDirectory(); { } TDirectory.Exists(); { } TDirectory.IsEmpty(); { } TDirectory.Copy(); { } TDirectory.Move(); { } TDirectory.Delete(); { , True }  TDirectory.GetDirectoryRoot(); { , : C:\} TDirectory.GetCurrentDirectory; { } TDirectory.SetCurrentDirectory(); { } TDirectory.GetLogicalDrives; { ; } TDirectory.GetAttributes(); { , 、 ; } TDirectory.SetAttributes(); { ; } // TFile.Exists();// TFile.Copy();// TFile.Move();// TFile.Delete();// TFile.Replace();// MotionSensor1: TMotionSensor; MotionSensor1.Sensor(AngleAccelX、AngleAccelY、AngleAccelZ) procedure TAccelerometerForm.Timer1Timer(Sender: TObject); var   LProp: TCustomMotionSensor.TProperty; begin    for LProp in MotionSensor1.Sensor.AvailableProperties do   begin     { get the data from the sensor }     case LProp of       TCustomMotionSensor.TProperty.AccelerationX:       begin         lbAccelerationX.Visible := True;         lbAccelerationX.Text := Format('Acceleration X: %6.2f', [MotionSensor1.Sensor.AccelerationX]);       end;    end; end; OrientationSensor1: TOrientationSensor; OrientationSensor1.Sensor(TiltX,TiltY,TiltZ) procedure TOrientationSensorForm.Timer1Timer(Sender: TObject); begin   { get the data from the sensor }   lbTiltX.Text := Format('Tilt X: %f', [OrientationSensor1.Sensor.TiltX]);   lbTiltY.Text := Format('Tilt Y: %f', [OrientationSensor1.Sensor.TiltY]);   lbTiltZ.Text := Format('Tilt Z: %f', [OrientationSensor1.Sensor.TiltZ]);   lbHeadingX.Text := Format('Heading X: %f', [OrientationSensor1.Sensor.HeadingX]);   lbHeadingY.Text := Format('Heading Y: %f', [OrientationSensor1.Sensor.HeadingY]);   lbHeadingZ.Text := Format('Heading Z: %f', [OrientationSensor1.Sensor.HeadingZ]); end; TSensorManager ( ,Samples\Object Pascal\Mobile Samples\Device Sensors and Services\SensorInfo) TSensorCategory = (Location, Environmental, Motion, Orientation, Mechanical, Electrical, Biometric, Light, Scanner); , , , , , , , , TActionList (New Standard Action) TakePhotoFromCameraAction1: TTakePhotoFromCameraAction; // TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction; // ShowShareSheetAction1: TShowShareSheetAction;// (Bitmap.Assign();)   FMX.Media FMicrophone: TAudioCaptureDevice; FMicrophone := TCaptureDeviceManager.Current.DefaultAudioCaptureDevice; FMicrophone.FileName FMicrophone.State = TCaptureDeviceState.Capturing FMicrophone.StartCapture; // FMicrophone.StopCapture; // MediaPlayer: TMediaPlayer; MediaPlayer.FileName MediaPlayer.Play; // MediaPlayer.Stop; // Camera: TCameraComponent; Camera.Active := True; // Camera.Active := False; // Camera.SampleBufferToBitmap(imgCameraView.Bitmap, True); //   TThread.Synchronize(TThread.CurrentThread, GetImage); // Camera.Quality Camera.HasFlash Camera.TorchMode := TTorchMode.ModeOn; // Camera.FlashMode := FMX.Media.TFlashMode.fmFlashOff; Camera.TorchMode := TTorchMode.ModeOff;// Camera.FlashMode := FMX.Media.TFlashMode.fmFlashOn; Camera.Kind := FMX.Media.TCameraKind.ckFrontCamera;// Camera.Kind := FMX.Media.TCameraKind.ckBackCamera;// lbDeviceType.Text := Format('Device Type: %s', [JStringToString(TJBuild.JavaClass.MODEL)]); lbOSName.Text := Format('OS Name: %s', [GetCodename(JStringToString(TJBuild_VERSION.JavaClass.RELEASE))]);  lbOSVersion.Text := Format('OS Version: %s', [JStringToString(TJBuild_VERSION.JavaClass.RELEASE)]); GestureManager1: TGestureManager; (igiRotate| 、igiZoom| 、igiLongTap| ) GestureManager1(Touch.GestureManager,Getures.Standard ) procedure TPinchZoom.FormGesture(Sender: TObject;   const EventInfo: TGestureEventInfo; var Handled: Boolean);  var   LObj: IControl;   LImage: TImage;   LImageCenter: TPointF; begin   if EventInfo.GestureID = igiZoom then   begin     LObj := Self.ObjectAtPoint(ClientToScreen(EventInfo.Location));     if LObj is TImage then     begin       if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) and         (not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags)) then       begin         { zoom the image }         LImage := TImage(LObj.GetObject);         LImageCenter := LImage.Position.Point + PointF(LImage.Width / 2,           LImage.Height / 2);         LImage.Width := LImage.Width + (EventInfo.Distance - FLastDistance);         LImage.Height := LImage.Height + (EventInfo.Distance - FLastDistance);         LImage.Position.X := LImageCenter.X - LImage.Width / 2;         LImage.Position.Y := LImageCenter.Y - LImage.Height / 2;       end;       FLastDistance := EventInfo.Distance;     end;   end; end; LocationSensor1: TLocationSensor;// LocationSensor1.Active := swLocationSensorActive.IsChecked; // NewLocation.Latitude // NewLocation.Longitude // FGeocoder: TGeocoder;// procedure TLocationForm.LocationSensor1LocationChanged(Sender: TObject;   const OldLocation, NewLocation: TLocationCoord2D); const   LGoogleMapsURL: String = 'https://maps.google.com/maps?q=%s,%s'; var   ENUSLat, ENUSLong: String; // holders for URL strings begin   ENUSLat := NewLocation.Latitude.ToString(ffGeneral, 5, 2, TFormatSettings.Create('en-US'));   ENUSLong := NewLocation.Longitude.ToString(ffGeneral, 5, 2, TFormatSettings.Create('en-US'));    { convert the location to latitude and longitude }   lbLatitude.Text := 'Latitude: ' + ENUSLat;   lbLongitude.Text := 'Longitude: ' + ENUSLong;   { and track the location via Google Maps }   WebBrowser1.Navigate(Format(LGoogleMapsURL, [ENUSLat, ENUSLong]));   // Setup an instance of TGeocoder   try     if not Assigned(FGeocoder) then     begin       if Assigned(TGeocoder.Current) then         FGeocoder := TGeocoder.Current.Create;       if Assigned(FGeocoder) then         FGeocoder.OnGeocodeReverse := OnGeocodeReverseEvent;     end;   except     ListBoxGroupHeader1.Text := 'Geocoder service error.';   end;   // Translate location to address   if Assigned(FGeocoder) and not FGeocoder.Geocoding then     FGeocoder.GeocodeReverse(NewLocation); end; // procedure TLocationForm.OnGeocodeReverseEvent(const Address: TCivicAddress); begin   ListBoxItemAdminArea.ItemData.Detail       := Address.AdminArea; //   ListBoxItemCountryCode.ItemData.Detail     := Address.CountryCode; // CN   ListBoxItemCountryName.ItemData.Detail     := Address.CountryName; //   ListBoxItemFeatureName.ItemData.Detail     := Address.FeatureName; //   ListBoxItemLocality.ItemData.Detail        := Address.Locality; //   ListBoxItemPostalCode.ItemData.Detail      := Address.PostalCode; //   ListBoxItemSubAdminArea.ItemData.Detail    := Address.SubAdminArea;//   ListBoxItemSubLocality.ItemData.Detail     := Address.SubLocality;//   ListBoxItemSubThoroughfare.ItemData.Detail := Address.SubThoroughfare;//   ListBoxItemThoroughfare.ItemData.Detail    := Address.Thoroughfare;// end;   FMX.Android.DeviceInfo.GetInformation;   Memo1.Lines.Add('ID:'+FMX.Android.DeviceInfo.ID);   Memo1.Lines.Add('IMEI:'+FMX.Android.DeviceInfo.IMEI);   Memo1.Lines.Add('User:'+FMX.Android.DeviceInfo.User);   Memo1.Lines.Add('Host:'+FMX.Android.DeviceInfo.Host);   Memo1.Lines.Add('Tags:'+FMX.Android.DeviceInfo.Tags);   Memo1.Lines.Add('Time:'+FMX.Android.DeviceInfo.Time);   Memo1.Lines.Add('AType:'+FMX.Android.DeviceInfo.AType);   Memo1.Lines.Add('Board:'+FMX.Android.DeviceInfo.Board);   Memo1.Lines.Add('Radio:'+FMX.Android.DeviceInfo.Radio);   Memo1.Lines.Add('Brand:'+FMX.Android.DeviceInfo.Brand);   Memo1.Lines.Add('Model:'+FMX.Android.DeviceInfo.Model);   Memo1.Lines.Add('Serial:'+FMX.Android.DeviceInfo.Serial);   Memo1.Lines.Add('Device:'+FMX.Android.DeviceInfo.Device);   Memo1.Lines.Add('CpuABI:'+FMX.Android.DeviceInfo.CpuABI);   Memo1.Lines.Add('CpuABI2:'+FMX.Android.DeviceInfo.CpuABI2);   Memo1.Lines.Add('Display:'+FMX.Android.DeviceInfo.Display);   Memo1.Lines.Add('Product:'+FMX.Android.DeviceInfo.Product);   Memo1.Lines.Add('Hardware:'+FMX.Android.DeviceInfo.Hardware);   Memo1.Lines.Add('Bootloader:'+FMX.Android.DeviceInfo.Bootloader);   Memo1.Lines.Add('FingerPrint:'+FMX.Android.DeviceInfo.FingerPrint);   Memo1.Lines.Add('Manufacturer:'+FMX.Android.DeviceInfo.Manufacturer); MapView1: TMapView;// WebBrowser1: TWebBrowser; // WebBrowser1.Navigate('www.baidu.com'); // WebBrowser1.URL := '';// WebBrowser1.GoForward; // WebBrowser1.GoBack;// ShowMessage、MessageDlg、InputQuery // ( , ) NotificationC: TNotificationCenter;  procedure TNotificationsForm.btnSendNotificationImmediatelyClick(   Sender: TObject); var   Notification: TNotification; begin   { verify if the service is actually supported }   if NotificationC.Supported then   begin     Notification := NotificationC.CreateNotification;     try       Notification.Name := 'MyNotification';       Notification.AlertBody := 'Delphi for Mobile is here!';       Notification.FireDate := Now; //       { Send notification in Notification Center }       NotificationC.ScheduleNotification(Notification);       { also this method is equivalent }       // NotificationService.PresentNotification(Notification);     finally       Notification.DisposeOf;     end;   end end;   if NotificationC.Supported then     NotificationC.CancelNotification('MyNotification'); //     NotificationC.CancelAll; // var   FMXApplicationEventService: IFMXApplicationEventService; begin   if TPlatformServices.Current.SupportsPlatformService (IFMXApplicationEventService, IInterface(FMXApplicationEventService)) then      FMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)   else      flag := false; end; function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject)   : boolean;  begin    if flag = false then     exit;   case AAppEvent of     TApplicationEvent.aeEnteredBackground:       begin           //       end;   end;   Result := 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:[email protected]'); // Call_URI(TJIntent.JavaClass.ACTION_VIEW, 'file:///sdcard/download/ .mp3'); procedure TForm1.Button3Click(Sender: TObject); var   Intent: JIntent; begin   Intent:= TJIntent.Create;   Intent.setAction(TJIntent.JavaClass.ACTION_MAIN);   Intent.addCategory(TJIntent.JavaClass.CATEGORY_HOME);   Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);   MainActivity.startActivity(Intent); end; ( zxing) procedure TINVMCForm.btnSCANClick(Sender: TObject); var   uri: Jnet_Uri;       // Androidapi.JNI.Net   Intent: JIntent;    // Androidapi.JNI.GraphicsContentViewText   jstr:JString; begin   inherited;   uri := StrToJURI('com.google.zxing.client.android.SCAN');  // FMX.Helpers.Android   //Intent := TJIntent.JavaClass.init(jstring(('com.google.zxing.client.android.SCAN');   Intent := TJIntent.JavaClass.init(StringToJString('com.google.zxing.client.android.SCAN'));   SharedActivityContext.startActivity(Intent); end; function GetZXingIntent: JIntent; const   GOOGLE_ZXING = 'com.google.zxing.client.android.SCAN';   GOOGLE_ZXING_PACKAGE = 'com.google.zxing.client.android'; begin   Result := TJIntent.JavaClass.init(StringToJString(GOOGLE_ZXING));   Result.setPackage(StringToJString(GOOGLE_ZXING_PACKAGE)); end; // function IsIntentCallable(const AIntent: JIntent): Boolean; var   LJPackageManager: JPackageManager; begin   Result := False;   if Assigned(AIntent) then   begin     LJPackageManager := SharedActivityContext.getPackageManager;     Result := LJPackageManager.queryIntentActivities(AIntent,       TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size <> 0;   end; end; 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;// var   Lindex:integer; begin   Result:=TJavaArray.Create(Length(AintArr));   for Lindex:=Low(AintArr) to High(AintArr) do       Result.Items [Lindex]:= AintArr[Lindex]; end; var    LVibrator:JVibrator;    LJavaArray:TJavaArray; 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; ( Server/Client) TTetheringManager| 、TTetheringAppProfile| System.Bluetooth TBluetoothManager、TBluetoothDeviceList、TBluetoothAdapter、TBluetoothDevice、TBluetoothService、 TBluetoothServiceList、TBluetoothSocket TBluetoothManager , , , , TBluetoothDeviceList ,TBluetoothDeviceList = class(TObjectList), TBluetoothManager.GetPairedDevices TBluetoothAdapter , 、 , TBluetoothManager.CurrentAdapter TBluetoothDevice , (TBluetoothService), TBluetoothService , UUID TBluetoothServiceList = class(TList); TBluetoothDevice.GetServices TBluetoothSocket , TBluetoothDevice.CreateClientSocket(StringToGUID(ServiceGUI), True/False) TimeEdit1: TTimeEdit;// HorzScrollBox1: THorzScrollBox; MultiView1: TMultiView;// (Mode , ) EMSProvider: TEMSProvider;// BBAS Client( TKinveyProvider、TParseProvider); TabItem1: TTabItem;// procedure TPForm.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;   Shift: TShiftState); begin   if Key = vkHardwareBack then   begin     {$IFDEF ANDROID}     MessageDlg('', System.UITypes.TMsgDlgType.mtInformation,     [       System.UITypes.TMsgDlgBtn.mbYes,       //System.UITypes.TMsgDlgBtn.mbNo,       System.UITypes.TMsgDlgBtn.mbCancel     ], 0, System.UITypes.TMsgDlgBtn.mbCancel,     procedure(const AResult: TModalResult)     begin       if AResult = mrYES then          MainActivity.finish; { }   // use FMX.Platform.Android       end);     {$ENDIF ANDROID}     //close;     Key := 0;     exit;   end; end; Application.FormFactor.Orientations := [TFormOrientation.Landscape]; // Application.FormFactor.Orientations := [TFormOrientation.Portrait];// (Androidapi.JNI.Network.pas) IsConnected| ,IsWiFiConnected|Wifi ,IsMobileConnected| 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; procedure Tform1.Button1Click(Sender: TObject); {$IFDEF ANDROID} var   ShortcutIntent: JIntent;   addIntent: JIntent;   wIconIdentifier : integer;   wIconResource : JIntent_ShortcutIconResource; {$ENDIF} begin {$IFDEF ANDROID}   ShortcutIntent := TJIntent.JavaClass.init(SharedActivityContext, SharedActivityContext.getClass);   ShortcutIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);   addIntent := TJIntent.Create;   addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, TJParcelable.Wrap((shortcutIntent as ILocalObject).GetObjectID));   addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, StringToJString(Application.Title));   addIntent.setAction(StringToJString('com.android.launcher.action.INSTALL_SHORTCUT'));   // get icon resource identifier   wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString('ic_launcher'), StringToJString('drawable'), StringToJString('com.embarcadero.Project1'));   wIconResource := TJIntent_ShortcutIconResource.JavaClass.fromContext(SharedActivityContext, wIconIdentifier);   // set icon for shortcut   addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, TJParcelable.Wrap((wIconResource as ILocalObject).GetObjectID));   SharedActivityContext.sendBroadcast(addIntent); {$ENDIF} end; function MakeScaleScreenshot(Sender: TControl): TBitmap;   function GetScreenScale: Single;   var     ScreenService: IFMXScreenService;   begin     Result := 1;     if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService,  IInterface(ScreenService)) then     begin       Result := ScreenService.GetScreenScale;     end;   end; var   fScreenScale: Single; begin    fScreenScale := GetScreenScale;   Result := TBitmap.Create(Round(Sender.Width * fScreenScale),     Round(Sender.Height * fScreenScale));   Result.Clear(0);   if Result.Canvas.BeginScene then     try       Sender.PaintTo(Result.Canvas, RectF(0, 0, Result.Width, Result.Height));     finally       Result.Canvas.EndScene;     end; end; ---------------------
 
転載先:https://www.cnblogs.com/m0488/p/9759483.html