FMX.ShareSheet Sample
This sample demonstrates how to use standard actions in order to open the Camera Application on your iOS or Android device, take a picture and share it with other services.
Contents
Location
You can find the ShareSheet sample project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
Object Pascal\Mobile Snippets\ShareSheet
CPP\Mobile Snippets\ShareSheet
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
The ShareSheet sample shows how to use standard actions in order take a picture with the Camera Application of your iOS or Android device, and share it with other services. The sample uses the TActionList component with two standard actions:
- TTakePhotoFromCameraAction to open the camera application on your iOS or Android device, take a picture and retrieve the taken image to display it on your FireMonkey form.
- TShowShareSheetAction to share the picture with other services (for example, in social networks, by email or Bluetooth).
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: ShareSheet.dproj.
- C++: ShareSheet.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Click the Take Photo button to open the camera window and take a picture.
- Click the Share button to open the sharing sheet to share the picture with other services.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
ShareSheet.dproj |
ShareSheet.cbproj |
The project itself. |
uMain.fmx |
uMain.fmx |
The main form where the components are located. |
uMain.pas |
ShareSheetPCH.h, ShareSheet.cpp |
Used to define and implement the sample. |
Information.txt |
Information.txt |
Further information about the sample. |
Classes
TShareSheetForm is the main form that represents the main window of the sample. It contains the following components:
- A TActionList object with two standard actions.
- A TTakePhotoFromCamera action.
- A TShowShareSheet action.
- A TImage object.
- Two ToolBar objects:
Implementation
- The sample uses TTakePhotoFromCameraAction to take photos from the camera device.
- The sample uses TImage to display and define 2D image components.
- The sample uses TShowShareSheetAction to share photos with other services.
- The sample uses two Tbuttons that are attached to both actions.
When you run the application, the sample shows a picture and two buttons labeled as Take Photo and Share. The TTakePhotoFromCamera action is attached to the Take Photo button, and the TShowShareSheet action is attached to the Share button.
- If you click the Take Photo button, the camera window is displayed and allows you to choose some camera properties (for example, the camera to be used (front or back)) and take a photo. Once the photo has been taken, the OnDidFinishTaking event assigns the image retrieved from the camera to the TImage component in order to display the photo on your FireMonkey form.
- If you click the Share button, the sharing sheet opens and allows you to share your picture with other services (for example, in social networks, by email or Bluetooth).
Uses
See Also
- Images
- Mobile Tutorial: Taking and Sharing Pictures (iOS and Android)
- Taking and Sharing Pictures and Text Using Action Lists
- Setting Up Action Lists
- Adding an Action to the Action List
Samples
- FireMonkey Acces Camera sample
- FireMonkey Camera Roll sample
- VCL Image Processing sample
- FireMonkey Image Zoom sample
- FireMonkey Image Rotation sample
- FireMonkey Actions sample
- Using Picture Dialogs (Delphi)
- Using Picture Dialogs (C++)