Hi to all.
I am trying in the application I have made, to save in a database on runtime photos that I take with the camera. If I just select save, everything works fine.
With the help of appCameraDemo I made the following code but it doesn't work. The message that comes out after some time is:
if no operation for a long time, the screen will enter the power saving state. About to exit camera or click on the screen to wake up.
And then return
resultCode = RESULT_CANCELED :
photo Canceled
I have set the camera resolution to 2MP although I would like more resolution.
If anyone can help...
procedure TFvisitland.Button16Click(Sender: TObject);
begin
if IsRuntimePermissionGranted('android.permission.CAMERA') and
IsRuntimePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then
begin
Camera1.Filename :=GetNameFarmer ;
Camera1.RequestCode := 12345;
Camera1.TakePhoto;
end
else ShowMessage('Sorry... Some Runtime Permission NOT Granted ...');
end;
procedure TFvisitland.FvisitlandActivityResult(Sender: TObject;
requestCode: integer; resultCode: TAndroidResult; intentData: jObject);
var
photoPath: string;
photo_id:integer;
begin
if resultCode = RESULT_CANCELED then
begin
ShowMessage('Photo Canceled!')
end
else if resultCode = RESULT_OK then //ok...
begin
if requestCode = Camera1.RequestCode then
begin
photoPath:= Camera1.FullPathToBitmapFile ;
Bitmap1.ImageIdentifier :=Camera1.FullPathToBitmapFile ;
// FIND LAST RECORD
DbVisitLandPhoto.close;
DbVisitLandPhoto.OpenOrCreate(dbname);
DbVisitLandPhoto.select('Select max(IDEPISK3) from Episkepsi4;') ; // Find Last record
photo_id:=DbVisitLandPhoto.Cursor.GetValueAsInteger(0) ;
Bitmap1.LoadFromFile(photoPath) ;
DbVisitLandPhoto.UpdateImage('EPISKEPSI4',
'FIGURE', // FIELD OF IMAGE
'IDEPISK3', // FIELD ID
Bitmap1,
photo_id);
end;
end
else
ShowMessage('Photo Fail!');
end;