# Class ShareResult

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

public final class ShareResult extends java.lang.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()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, 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()
    Overrides:
      `toString` in class `java.lang.Object`