# Class ShareService

java.lang.Object
com.codename1.ui.Command
com.codename1.share.ShareService

All Implemented Interfaces:
  `ActionListener<ActionEvent>`

Direct Known Subclasses:
  `EmailShare, FacebookShare, SMSShare`

public abstract class ShareService extends Command
This is an abstract sharing service.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ShareService(String name, Image icon)`
  Constructor with the service name and icon

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `actionPerformed(ActionEvent evt)`
  This method is called when the soft button/Menu item is clicked
  `abstract boolean`
  `canShareImage()`
  The implementing service needs to declare if it is capable to share an image
  `void`
  `finish()`
  Once the share service has finished sharing it should call the finish method
  `Form`
  `getOriginal()`
  Gets the original Form
  `void`
  `setImage(String image, String mime)`
  Sets the image to share, this is done by the ShareButton and shouldn't be used by the developers
  `void`
  `setMessage(String message)`
  Sets the message to share, this is done by the ShareButton and shouldn't be used by the developers
  `void`
  `setOriginalForm(Form original)`
  Sets the Original Form (this is the Form of the share button)
  `abstract void`
  `share(String text)`
  This is the sharing method which should be implemented by the service.
  `void`
  `share(String text, String image, String imageMimeType)`
  This is the image sharing method which should be implemented by the service, if the service returned true on the canShareImage() method Notice not all services are able to share text and image together, in this case the image sharing will be preferred by these services

  ### Methods inherited from class Command

  `create, createMaterial, equals, getClientProperty, getCommandName, getDisabledIcon, getIcon, getIconFont, getIconGapMM, getId, getMaterialIcon, getMaterialIconSize, getPressedIcon, getRolloverIcon, hashCode, isDisposesDialog, isEnabled, putClientProperty, setCommandName, setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setIconFont, setIconGapMM, setMaterialIcon, setMaterialIconSize, setPressedIcon, setRolloverIcon, toString`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ShareService

    public ShareService(String name, Image icon)

    Constructor with the service name and icon

    ###### Parameters

    - `name`: the service name

    - `icon`: the service icon

- ## Method Details

  - ### actionPerformed

    public void actionPerformed(ActionEvent evt)

    This method is called when the soft button/Menu item is clicked

    ###### Parameters

    - `evt`: the Event Object
    Specified by:
      `actionPerformed` in interface `ActionListener<ActionEvent>`
    Overrides:
      `actionPerformed` in class `Command`

  - ### share

    public abstract void share(String text)

    This is the sharing method which should be implemented by the service.

    ###### Parameters

    - `text`: text to share

  - ### share

    public void share(String text, String image, String imageMimeType)

    This is the image sharing method which should be implemented by the service, if the service returned true on the canShareImage() method Notice not all services are able to share text and image together, in this case the image sharing will be preferred by these services

    ###### Parameters

    - `text`: text to share

    - `image`: image to share

  - ### canShareImage

    public abstract boolean canShareImage()

    The implementing service needs to declare if it is capable to share an image

    ###### Returns

    true if the service can share images

  - ### setMessage

    public void setMessage(String message)

    Sets the message to share, this is done by the ShareButton and shouldn't be used by the developers

    ###### Parameters

    - `message`

  - ### setImage

    public void setImage(String image, String mime)

    Sets the image to share, this is done by the ShareButton and shouldn't be used by the developers

    ###### Parameters

    - `image`: the file path to the image

    - `mime`: the image mime type e.g. image/png, image/jpeg

  - ### setOriginalForm

    public void setOriginalForm(Form original)
    Sets the Original Form (this is the Form of the share button)

  - ### getOriginal

    public Form getOriginal()
    Gets the original Form

  - ### finish

    public void finish()
    Once the share service has finished sharing it should call the finish method