Class DynamicLinkUtils

java.lang.Object
com.pranavpandey.android.dynamic.util.DynamicLinkUtils

public class DynamicLinkUtils extends Object
Helper class to perform URL, email and feedback related operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    addContact(Context context, String[] names, String[] nicknames, String pronunciation, String[] phones, String[] phoneTypes, String[] emails, String[] emailTypes, String[] addresses, String[] addressTypes, String birthday, String title, String organization, String[] websites, String note)
    Launch add contact intent according to the supplied parameters.
    static boolean
    addEvent(Context context, String title, long startTime, long endTime, boolean allDay, String organizer, String location, String description)
    Launch add calendar event intent according to the supplied parameters.
    static boolean
    bookmark(Context context, String url, String title)
    View or bookmark URL according to the supplied parameters.
    static boolean
    call(Context context, String number)
    Launch call intent for the supplied number.
    static boolean
    copyToClipboard(Context context, String label, String text)
    Copy a plain text to the clipboard.
    static boolean
    email(Context context, String[] emails, String[] ccEmails, String[] bccEmails, String subject, String text)
    Send email according to the supplied parameters.
    static boolean
    email(Context context, String[] emails, String subject, String text)
    Send email according to the supplied parameters.
    static boolean
    email(Context context, String email, String subject, String text)
    Send email according to the supplied parameters.
    static boolean
    feedback(Context context, String appName, String email)
    Ask questions or submit bug report to the developer via Google feedback.
    static boolean
    feedback(Context context, String appName, String email, int reportType, ApplicationErrorReport.CrashInfo crashInfo)
    Ask questions or submit bug report to the developer via Google feedback.
    static boolean
    geoLocation(Context context, String latitude, String longitude)
    Try to view location URL according to the supplied parameters.
    static boolean
    geoLocation(Context context, String latitude, String longitude, String altitude, String query)
    Try to view location URL according to the supplied parameters.
    static boolean
    Checks whether the email client exists on the device.
    static boolean
    Checks whether the feedback functionality exists on the device.
    static boolean
    Checks whether the GMS (Google Mobile Services) package exists on the device.
    static boolean
    Checks whether the Google feedback package exists on the device.
    static boolean
    moreApps(Context context, String publisher)
    View other apps of a Publisher on Google Play or Android Market.
    static boolean
    moreAppsSamsung(Context context, String publisher)
    View other apps of a Samsung Galaxy Store.
    static boolean
    rateApp(Context context)
    View app on Google Play or Android Market.
    static boolean
    rateApp(Context context, String flavor)
    View app on Google Play or Android Market.
    static boolean
    report(Context context, String appName, String email)
    Ask questions or submit bug report to the developer via email.
    static boolean
    report(Context context, String appName, String email, Boolean license)
    Ask questions or submit bug report to the developer via email.
    static boolean
    share(Context context, String title, String message)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    share(Context context, String title, String message, Uri image)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    share(Context context, String title, String message, Uri image, String flavor)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    share(Context context, String title, String message, Uri uri, String mimeType, String flavor)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    share(Context context, String title, String message, String flavor)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    shareApp(Context context)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    shareApp(Context context, String flavor)
    Share application via system default share intent so that user can select from the available apps if more than one apps are available.
    static boolean
    smsOrMms(Context context, String[] numbers, String subject, String text)
    Launch SMS or MMS intent according to the supplied parameters.
    static boolean
    viewApp(Context context, String packageName)
    View app on Google Play (or Android Market) or Samsung Galaxy Store if available.
    static boolean
    viewApp(Context context, String packageName, String flavor)
    View app on Google Play (or Android Market) or Samsung Galaxy Store if available.
    static boolean
    viewAppExternal(Context context, String packageName)
    View app on Google Play (or Android Market) or Samsung Galaxy Store if available.
    static boolean
    viewInGooglePlay(Context context, String packageName)
    View app on Google Play or Android Market.
    static boolean
    viewInSamsungGalaxyStore(Context context, String packageName)
    View app on Samsung Galaxy Store.
    static boolean
    viewUrl(Context context, String url)
    View any URL in the available app or browser.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DynamicLinkUtils

      public DynamicLinkUtils()
  • Method Details

    • copyToClipboard

      public static boolean copyToClipboard(@NonNull Context context, @NonNull String label, @NonNull String text)
      Copy a plain text to the clipboard.
      Parameters:
      context - The context to get the clipboard manager.
      label - The user visible label for the clip data.
      text - The actual text in the clip.
      Returns:
      true if copied to clipboard successfully.
      See Also:
    • share

      public static boolean share(@Nullable Context context, @Nullable String title, @Nullable String message, @Nullable Uri uri, @Nullable String mimeType, String flavor)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      title - The application chooser title if more than one apps are available.
      message - The default share message which user can modify.

      null to supply app and package name.

      uri - The optional content URI to be shared.
      mimeType - The optional mime type for the file.
      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • share

      public static boolean share(@Nullable Context context, @Nullable String title, @Nullable String message, @Nullable Uri image, String flavor)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      title - The application chooser title if more than one apps are available.
      message - The default share message which user can modify.

      null to supply app and package name.

      image - The optional image bitmap URI to be shared.
      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • share

      public static boolean share(@Nullable Context context, @Nullable String title, @Nullable String message, @Nullable Uri image)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      title - The application chooser title if more than one apps are available.
      message - The default share message which user can modify.

      null to supply app and package name.

      image - The optional image bitmap URI to be shared.
      Returns:
      true on successful operation.
      See Also:
    • share

      public static boolean share(@Nullable Context context, @Nullable String title, @Nullable String message, String flavor)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      title - The application chooser title if more than one apps are available.
      message - The default share message which user can modify.

      null to supply app and package name.

      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • share

      public static boolean share(@Nullable Context context, @Nullable String title, @Nullable String message)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      title - The application chooser title if more than one apps are available.
      message - The default share message which user can modify.

      null to supply app and package name.

      Returns:
      true on successful operation.
      See Also:
    • shareApp

      public static boolean shareApp(@Nullable Context context, String flavor)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • shareApp

      public static boolean shareApp(@Nullable Context context)
      Share application via system default share intent so that user can select from the available apps if more than one apps are available.
      Parameters:
      context - The context to be used.
      Returns:
      true on successful operation.
      See Also:
    • viewUrl

      public static boolean viewUrl(@Nullable Context context, @Nullable String url)
      View any URL in the available app or browser. Some URLs will automatically open in their respective apps if installed on the device. Special treatment is applied for the Facebook URLs to open them directly in the app.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      url - The web or app link to open.
      Returns:
      true on successful operation.
      See Also:
    • viewInGooglePlay

      public static boolean viewInGooglePlay(@Nullable Context context, @NonNull String packageName)
      View app on Google Play or Android Market.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      packageName - The app package name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • viewInSamsungGalaxyStore

      public static boolean viewInSamsungGalaxyStore(@Nullable Context context, @NonNull String packageName)
      View app on Samsung Galaxy Store.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      packageName - The app package name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • viewApp

      public static boolean viewApp(@Nullable Context context, @NonNull String packageName, String flavor)
      View app on Google Play (or Android Market) or Samsung Galaxy Store if available.

      Can be used to view app details within the supported stores.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      packageName - The app package name to build the search query.
      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • viewApp

      public static boolean viewApp(@Nullable Context context, @NonNull String packageName)
      View app on Google Play (or Android Market) or Samsung Galaxy Store if available.

      Can be used to view app details within the supported stores.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      packageName - The app package name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • viewAppExternal

      public static boolean viewAppExternal(@Nullable Context context, @NonNull String packageName)
      View app on Google Play (or Android Market) or Samsung Galaxy Store if available. External stores will be preferred first.

      Can be used to view app details within the supported stores.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      packageName - The app package name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • rateApp

      public static boolean rateApp(@Nullable Context context, String flavor)
      View app on Google Play or Android Market.

      Can be used for the quick feedback or rating from the user.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      flavor - The product flavor to be used.
      Returns:
      true on successful operation.
      See Also:
    • rateApp

      public static boolean rateApp(@Nullable Context context)
      View app on Google Play or Android Market.

      Can be used for the quick feedback or rating from the user.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      Returns:
      true on successful operation.
      See Also:
    • moreApps

      public static boolean moreApps(@Nullable Context context, @NonNull String publisher)
      View other apps of a Publisher on Google Play or Android Market.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      publisher - The publisher name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • moreAppsSamsung

      public static boolean moreAppsSamsung(@Nullable Context context, @NonNull String publisher)
      View other apps of a Samsung Galaxy Store.

      Use queries tag for Intent.ACTION_VIEW with scheme https or http in AndroidManifest to support API 30.

      Parameters:
      context - The context to be used.
      publisher - The publisher name to build the search query.
      Returns:
      true on successful operation.
      See Also:
    • email

      public static boolean email(@Nullable Context context, @Nullable String[] emails, @Nullable String[] ccEmails, @Nullable String[] bccEmails, @Nullable String subject, @Nullable String text)
      Send email according to the supplied parameters.
      Parameters:
      context - The context to be used.
      emails - The email ids to be used.
      ccEmails - The cc email ids to be used.
      bccEmails - The bcc email ids to be used.
      subject - The optional email subject.
      text - The optional email text.
      Returns:
      true on successful operation.
      See Also:
    • email

      public static boolean email(@Nullable Context context, @Nullable String[] emails, @Nullable String subject, @Nullable String text)
      Send email according to the supplied parameters.
      Parameters:
      context - The context to be used.
      emails - The email ids to be used.
      subject - The optional email subject.
      text - The optional email text.
      Returns:
      true on successful operation.
      See Also:
    • email

      public static boolean email(@Nullable Context context, @Nullable String email, @Nullable String subject, @Nullable String text)
      Send email according to the supplied parameters.
      Parameters:
      context - The context to be used.
      email - The email ids to be used.
      subject - The optional email subject.
      text - The optional email text.
      Returns:
      true on successful operation.
      See Also:
    • report

      public static boolean report(@Nullable Context context, @Nullable String appName, @Nullable String email, Boolean license)
      Ask questions or submit bug report to the developer via email.

      Subject of the email will be generated automatically by detecting the manufacturer, device, Android version and the app version along with the supplied app name.

      Parameters:
      context - The context to be used.
      appName - The app name for the email subject.

      null to get it from the supplied context.

      email - The email id of the developer.
      license - true if the license is available on the devices.
      Returns:
      true on successful operation.
      See Also:
    • report

      public static boolean report(@Nullable Context context, @Nullable String appName, @NonNull String email)
      Ask questions or submit bug report to the developer via email.

      Subject of the email will be generated automatically by detecting the manufacturer, device, Android version and the app version along with the supplied app name.

      Parameters:
      context - The context to be used.
      appName - The app name for the email subject.

      null to get it from the supplied context.

      email - The email id of the developer.
      Returns:
      true on successful operation.
      See Also:
    • isEmailExists

      public static boolean isEmailExists(@Nullable Context context)
      Checks whether the email client exists on the device.

      Use queries tag for Intent.ACTION_SENDTO with scheme MailTo.MAILTO_SCHEME in AndroidManifest to support API 30.

      Parameters:
      context - The context to get the package manager.
      Returns:
      true if the email client exists on the device.
    • isGMSExists

      public static boolean isGMSExists(@Nullable Context context)
      Checks whether the GMS (Google Mobile Services) package exists on the device.
      Parameters:
      context - The context to get the package manager.
      Returns:
      true if the GMS (Google Mobile Services) package exists on the device.
    • isGoogleFeedbackExists

      public static boolean isGoogleFeedbackExists(@Nullable Context context)
      Checks whether the Google feedback package exists on the device.
      Parameters:
      context - The context to get the package manager.
      Returns:
      true if the Google feedback package exists on the device.
    • isFeedbackExists

      public static boolean isFeedbackExists(@Nullable Context context)
      Checks whether the feedback functionality exists on the device.
      Parameters:
      context - The context to get the package manager.
      Returns:
      true if the feedback functionality exists on the device.
      See Also:
    • feedback

      public static boolean feedback(@Nullable Context context, @Nullable String appName, @NonNull String email, int reportType, @Nullable ApplicationErrorReport.CrashInfo crashInfo)
      Ask questions or submit bug report to the developer via Google feedback.

      It will redirect to report(Context, String, String) method if feedback package is not available on the device.

      Parameters:
      context - The context to be used.
      appName - The app name for the email subject.

      null to get it from the supplied context.

      email - The email id of the developer.
      reportType - The crash report type.

      Can be one of ApplicationErrorReport.TYPE_NONE, ApplicationErrorReport.TYPE_CRASH, ApplicationErrorReport.TYPE_ANR, ApplicationErrorReport.TYPE_BATTERY, or ApplicationErrorReport.TYPE_RUNNING_SERVICE.

      crashInfo - The crash info for the report.
      Returns:
      true on successful operation.
      See Also:
    • feedback

      public static boolean feedback(@Nullable Context context, @Nullable String appName, @NonNull String email)
      Ask questions or submit bug report to the developer via Google feedback.

      It will redirect to report(Context, String, String) method if feedback package is not available on the device.

      Parameters:
      context - The context to be used.
      appName - The app name for the email subject.

      null to get it from the supplied context.

      email - The email id of the developer.
      Returns:
      true on successful operation.
      See Also:
    • bookmark

      public static boolean bookmark(@Nullable Context context, @Nullable String url, @Nullable String title)
      View or bookmark URL according to the supplied parameters.
      Parameters:
      context - The context to be used.
      url - The URL to be used.
      title - The optional title to launch the bookmark intent.
      Returns:
      true on successful operation.
      See Also:
    • call

      public static boolean call(@Nullable Context context, @Nullable String number)
      Launch call intent for the supplied number.
      Parameters:
      context - The context to be used.
      number - The number to be called.
      Returns:
      true on successful operation.
      See Also:
    • smsOrMms

      public static boolean smsOrMms(@Nullable Context context, @Nullable String[] numbers, @Nullable String subject, @Nullable String text)
      Launch SMS or MMS intent according to the supplied parameters.
      Parameters:
      context - The context to be used.
      numbers - The numbers to be used.
      subject - The optional subject if MMS.
      text - The body text to be used.
      Returns:
      true on successful operation.
      See Also:
    • geoLocation

      public static boolean geoLocation(@Nullable Context context, @Nullable String latitude, @Nullable String longitude, @Nullable String altitude, @Nullable String query)
      Try to view location URL according to the supplied parameters.
      Parameters:
      context - The context to be used.
      latitude - The latitude to be used.
      longitude - The longitude to be used.
      altitude - The optional altitude to be used.
      query - The optional custom query to be used.
      Returns:
      true on successful operation.
      See Also:
    • geoLocation

      public static boolean geoLocation(@Nullable Context context, @Nullable String latitude, @Nullable String longitude)
      Try to view location URL according to the supplied parameters.
      Parameters:
      context - The context to be used.
      latitude - The latitude to be used.
      longitude - The longitude to be used.
      Returns:
      true on successful operation.
      See Also:
    • addContact

      public static boolean addContact(@Nullable Context context, @Nullable String[] names, @Nullable String[] nicknames, @Nullable String pronunciation, @Nullable String[] phones, @Nullable String[] phoneTypes, @Nullable String[] emails, @Nullable String[] emailTypes, @Nullable String[] addresses, @Nullable String[] addressTypes, @Nullable String birthday, @Nullable String title, @Nullable String organization, @Nullable String[] websites, @Nullable String note)
      Launch add contact intent according to the supplied parameters.
      Parameters:
      context - The context to be used.
      names - The names to be used.
      nicknames - The nicknames to be used.
      pronunciation - The pronunciation to be used.
      phones - The phones to be used.
      phoneTypes - The phone types to be used.
      emails - The emails to be used.
      emailTypes - The email types to be used.
      addresses - The addresses to be used.
      addressTypes - The address types to be used.
      birthday - The birthday to be used.
      organization - The organization to be used.
      title - The title to be used.
      websites - The websites to be used.
      note - The note to be used.
      Returns:
      true on successful operation.
      See Also:
    • addEvent

      public static boolean addEvent(@Nullable Context context, @Nullable String title, long startTime, long endTime, boolean allDay, @Nullable String organizer, @Nullable String location, @Nullable String description)
      Launch add calendar event intent according to the supplied parameters.
      Parameters:
      context - The context to be used.
      title - The title (summary) to be used.
      startTime - The start time to be used.
      endTime - The end time to be used.
      allDay - true if the event is all day.
      organizer - The organizer tobe used.
      location - The location to be used.
      description - The description to be used.
      Returns:
      true on successful operation.
      See Also: