unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Actions,
FMX.ActnList, FMX.StdActns, FMX.MediaLibrary.Actions, FMX.Objects,
FMX.StdCtrls, FMX.Controls.Presentation, System.Permissions, FMX.DialogService,
{$IFDEF ANDROID}
Androidapi.Jni.Os,
Androidapi.Helpers
{$ENDIF};
type
TForm1 =
class(TForm)
ToolBar1: TToolBar;
btnCaptureImage: TButton;
btnSearchImage: TButton;
btnShare: TButton;
Image1: TImage;
ActionList1: TActionList;
TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
FPermissionCamera:
string;
FPermissionReadStorage:
string;
FPermissionWriteStorage:
string;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormShow(Sender: TObject);
begin
FPermissionCamera := JStringToString(TJManifest_permission.JavaClass.CAMERA);
FPermissionReadStorage := JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
FPermissionWriteStorage := JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE);
PermissionsService.RequestPermissions([FPermissionCamera,FPermissionReadStorage,FPermissionWriteStorage],
procedure(
const APermissions: TArray<
string>;
const AGrantResults: TArray<TPermissionStatus>)
begin
if (Length(AGrantResults) = 3)
and (AGrantResults[0] = TPermissionStatus.Granted)
and (AGrantResults[1] = TPermissionStatus.Granted)
and (AGrantResults[2] = TPermissionStatus.Granted)
then
TDialogService.ShowMessage('
permissions granted')
else
begin
TDialogService.ShowMessage('
permissions not granted');
end;
end
);
end;
procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end;
end.