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 Details

  • 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()
    • 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