简体   繁体   中英

delphi android firemonkey camera launch

I want to launch the phones native camera application from within my application. So I don't have to recreate a picture taking application. How do I do it.

Using 10.21

thanks robert

On Android, the tool called adb (bundled with Android SDK) is the bridge between computer and device. You can run commands from a terminal in order to interact with many features of Android OS.

With Delphi, your application can run the commands directly in cmd .

In order to take a picture, you can follow the tutorial here .

Then just pull the generated file from device, for instance adb pull /path/to/filename.jpg %USERPROFILE%\\Desktop\\ .

From a Delphi app you can use a TActionList and it's standard action TakePhotoFromCameraAction.

To use it from a button, add a TActionList to your form, on the button set Action property to TakePhotoFromCameraAction.

With code only:

  • add unit FMX.MediaLibrary.Actions
  • create a varaible TakePhotoFromCameraAction1 of type TTakePhotoFromCameraAction
  • set it's TakePhotoFromCameraAction1.DidFinishTaking event to a method like this :

    procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap); begin //... end;

  • call TakePhotoFromCameraAction1.Execute when needed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM