FMX.ShareSheet Sample

From RAD Studio Code Examples
Jump to: navigation, search

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.

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

  1. Navigate to one of the locations given above and open:
    • Delphi: ShareSheet.dproj.
    • C++: ShareSheet.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. 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:

Implementation

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

Samples