# Class ShareResult

java.lang.Object
com.codename1.share.ShareResult

public final class ShareResult extends Object

Outcome of a share request initiated through `Display.share(String)` or `ShareButton`.

Status semantics:

- `SHARED_TO`: the user picked a target and the system accepted the share. `getPackageName()` returns the chosen target's identifier: the Android package name (e.g. `com.whatsapp`) or, on iOS, the `UIActivityType` (e.g. `com.apple.UIKit.activity.PostToTwitter`).
- `DISMISSED`: the user cancelled the share sheet without picking a target.
- `FAILED`: the share could not be completed. `getError()` may carry a short, platform-supplied description (no stack traces).

Instances are immutable. Construct through the static factories.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `STATUS_DISMISSED`
  User dismissed/cancelled the share sheet.
  `static final int`
  `STATUS_FAILED`
  Share could not be completed.
  `static final int`
  `STATUS_SHARED_TO`
  Status of a `ShareResult`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ShareResult`
  `dismissed()`
  Build a `DISMISSED` result.
  `static ShareResult`
  `failed(String message)`
  Build a `FAILED` result with an optional platform message.
  `String`
  `getError()`
  Platform-supplied message when `isFailed()` is true, otherwise null.
  `String`
  `getPackageName()`
  Chosen target identifier when the user picked a destination, otherwise null.
  `int`
  `getStatus()`
  Numeric status: one of `STATUS_SHARED_TO`, `STATUS_DISMISSED`, `STATUS_FAILED`.
  `boolean`
  `isDismissed()`
  True iff status == `STATUS_DISMISSED`.
  `boolean`
  `isFailed()`
  True iff status == `STATUS_FAILED`.
  `boolean`
  `isSharedTo()`
  True iff status == `STATUS_SHARED_TO`.
  `static ShareResult`
  `sharedTo(String packageName)`
  Build a `SHARED_TO` result.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### STATUS_SHARED_TO

    public static final int STATUS_SHARED_TO
    Status of a `ShareResult`.
    See Also:
      - Constant Field Values

  - ### STATUS_DISMISSED

    public static final int STATUS_DISMISSED
    User dismissed/cancelled the share sheet.
    See Also:
      - Constant Field Values

  - ### STATUS_FAILED

    public static final int STATUS_FAILED
    Share could not be completed.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### sharedTo

    public static ShareResult sharedTo(String packageName)

    Build a `SHARED_TO` result.

    `packageName` is the platform-specific identifier of the chosen target (Android package name or iOS `UIActivityType`). It may be `null` when the platform does not expose the selection (older Android versions, web share API).

  - ### dismissed

    public static ShareResult dismissed()
    Build a `DISMISSED` result.

  - ### failed

    public static ShareResult failed(String message)
    Build a `FAILED` result with an optional platform message.

  - ### getStatus

    public int getStatus()
    Numeric status: one of `STATUS_SHARED_TO`, `STATUS_DISMISSED`, `STATUS_FAILED`.

  - ### isSharedTo

    public boolean isSharedTo()
    True iff status == `STATUS_SHARED_TO`.

  - ### isDismissed

    public boolean isDismissed()
    True iff status == `STATUS_DISMISSED`.

  - ### isFailed

    public boolean isFailed()
    True iff status == `STATUS_FAILED`.

  - ### getPackageName

    public String getPackageName()
    Chosen target identifier when the user picked a destination, otherwise null.

  - ### getError

    public String getError()
    Platform-supplied message when `isFailed()` is true, otherwise null.

  - ### toString

    public String toString()
    Description copied from class: `Object`
    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
    Overrides:
      `toString` in class `Object`