简体   繁体   English

Delphi Android Firemonkey相机启动

[英]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 使用10.21

thanks robert 谢谢罗伯特

On Android, the tool called adb (bundled with Android SDK) is the bridge between computer and device. 在Android上,称为adb (与Android SDK捆绑在一起)的工具是计算机和设备之间的桥梁。 You can run commands from a terminal in order to interact with many features of Android OS. 您可以从终端运行命令,以便与Android OS的许多功能进行交互。

With Delphi, your application can run the commands directly in cmd . 使用Delphi,您的应用程序可以直接在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\\ . 然后只需从设备中提取生成的文件,例如adb pull /path/to/filename.jpg %USERPROFILE%\\Desktop\\

From a Delphi app you can use a TActionList and it's standard action TakePhotoFromCameraAction. 从Delphi应用程序中,您可以使用TActionList及其标准动作TakePhotoFromCameraAction。

To use it from a button, add a TActionList to your form, on the button set Action property to TakePhotoFromCameraAction. 要通过按钮使用它,请在将Action属性设置为TakePhotoFromCameraAction的按钮上,将TActionList添加到窗体中。

With code only: 仅使用代码:

  • add unit FMX.MediaLibrary.Actions 添加单元FMX.MediaLibrary.Actions
  • create a varaible TakePhotoFromCameraAction1 of type TTakePhotoFromCameraAction 创建类型为TTakePhotoFromCameraAction的可变TakePhotoFromCameraAction1
  • set it's TakePhotoFromCameraAction1.DidFinishTaking event to a method like this : 将它的TakePhotoFromCameraAction1.DidFinishTaking事件设置为这样的方法:

    procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap); 过程TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image:TBitmap); begin //... end; 开始// ...结束;

  • call TakePhotoFromCameraAction1.Execute when needed 调用TakePhotoFromCameraAction1。需要时执行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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