Public Member Functions | List of all members
ContentSharer Class Reference

A singleton class responsible for sharing content between apps and devices. More...

Inheritance diagram for ContentSharer:

Public Member Functions

void shareFiles (const Array< URL > &files, std::function< void(bool, const String &)> callback)
 Shares the given files. More...
 
void shareText (const String &text, std::function< void(bool, const String &)> callback)
 Shares the given text. More...
 
void shareImages (const Array< Image > &images, std::function< void(bool, const String &)> callback, ImageFileFormat *imageFileFormatToUse=nullptr)
 A convenience function to share an image. More...
 
void shareData (const MemoryBlock &mb, std::function< void(bool, const String &)> callback)
 A convenience function to share arbitrary data. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DeletedAtShutdown
static void deleteAll ()
 Deletes all extant objects. More...
 
- Protected Member Functions inherited from DeletedAtShutdown
 DeletedAtShutdown ()
 Creates a DeletedAtShutdown object. More...
 
virtual ~DeletedAtShutdown ()
 Destructor. More...
 

Detailed Description

A singleton class responsible for sharing content between apps and devices.

You can share text, images, files or an arbitrary data block.

Member Function Documentation

◆ shareFiles()

void ContentSharer::shareFiles ( const Array< URL > &  files,
std::function< void(bool, const String &)>  callback 
)

Shares the given files.

Each URL should be either a full file path or it should point to a resource within the application bundle. For resources on iOS it should be something like "content/image.png" if you want to specify a file from application bundle located in "content" directory. On Android you should specify only a filename, without an extension.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareText()

void ContentSharer::shareText ( const String text,
std::function< void(bool, const String &)>  callback 
)

Shares the given text.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareImages()

void ContentSharer::shareImages ( const Array< Image > &  images,
std::function< void(bool, const String &)>  callback,
ImageFileFormat imageFileFormatToUse = nullptr 
)

A convenience function to share an image.

This is useful when you have images loaded in memory. The images will be written to temporary files first, so if you have the images in question stored on disk already call shareFiles() instead. By default, images will be saved to PNG files, but you can supply a custom ImageFileFormat to override this. The custom file format will be owned and deleted by the sharer. e.g.

Graphics g (myImage);
g.setColour (Colours::green);
g.fillEllipse (20, 20, 300, 200);
Array<Image> images;
images.add (myImage);
ContentSharer::getInstance()->shareImages (images, myCallback);

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareData()

void ContentSharer::shareData ( const MemoryBlock mb,
std::function< void(bool, const String &)>  callback 
)

A convenience function to share arbitrary data.

The data will be written to a temporary file and then that file will be shared. If you have your data stored on disk already, call shareFiles() instead.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.


The documentation for this class was generated from the following file:
gl::g
GLboolean GLboolean g
Definition: juce_gl.h:1934
Graphics
A graphics context, used for drawing a component or image.
Definition: juce_GraphicsContext.h:47
Array
Holds a resizable array of primitive or copy-by-value objects.
Definition: juce_Array.h:58
Array::add
void add(const ElementType &newElement)
Appends a new element at the end of the array.
Definition: juce_Array.h:421
Colours::green
const Colour green
Definition: juce_Colours.h:97