Class DynamicLinkUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean copyToClipboard​(android.content.Context context, java.lang.String label, java.lang.String text)
      Copy a plain text to the clipboard.
      static boolean email​(android.content.Context context, java.lang.String[] emails, java.lang.String subject, java.lang.String text)
      Ask questions or submit bug report to the developer via email.
      static boolean email​(android.content.Context context, java.lang.String email, java.lang.String subject, java.lang.String text)
      Ask questions or submit bug report to the developer via email.
      static boolean feedback​(android.content.Context context, java.lang.String appName, java.lang.String email)
      Ask questions or submit bug report to the developer via Google feedback.
      static boolean feedback​(android.content.Context context, java.lang.String appName, java.lang.String email, int reportType, android.app.ApplicationErrorReport.CrashInfo crashInfo)
      Ask questions or submit bug report to the developer via Google feedback.
      static boolean isEmailExists​(android.content.Context context)
      Checks whether the email client exists on the device.
      static boolean isFeedbackExists​(android.content.Context context)
      Checks whether the feedback functionality exists on the device.
      static boolean isGMSExists​(android.content.Context context)
      Checks whether the GMS (Google Mobile Services) package exists on the device.
      static boolean isGoogleFeedbackExists​(android.content.Context context)
      Checks whether the Google feedback package exists on the device.
      static boolean moreApps​(android.content.Context context, java.lang.String publisher)
      View other apps of a Publisher on Google Play or Android Market.
      static boolean rateApp​(android.content.Context context)
      View app on Google Play or Android Market.
      static boolean report​(android.content.Context context, java.lang.String appName, java.lang.String email)
      Ask questions or submit bug report to the developer via email.
      static boolean report​(android.content.Context context, java.lang.String appName, java.lang.String email, java.lang.Boolean license)
      Ask questions or submit bug report to the developer via email.
      static boolean share​(android.content.Context context, java.lang.String title, java.lang.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​(android.content.Context context, java.lang.String title, java.lang.String message, android.net.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​(android.content.Context context, java.lang.String title, java.lang.String message, android.net.Uri uri, java.lang.String mimeType)
      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​(android.content.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 viewInGooglePlay​(android.content.Context context, java.lang.String packageName)
      View app on Google Play or Android Market.
      static boolean viewUrl​(android.content.Context context, java.lang.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 Detail

      • DynamicLinkUtils

        public DynamicLinkUtils()
    • Method Detail

      • copyToClipboard

        public static boolean copyToClipboard​(@NonNull
                                              android.content.Context context,
                                              @NonNull
                                              java.lang.String label,
                                              @NonNull
                                              java.lang.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:
        ClipboardManager
      • share

        public static boolean share​(@Nullable
                                    android.content.Context context,
                                    @Nullable
                                    java.lang.String title,
                                    @Nullable
                                    java.lang.String message,
                                    @Nullable
                                    android.net.Uri uri,
                                    @Nullable
                                    java.lang.String mimeType)
        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 retrieve the resources.
        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.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_SEND
      • share

        public static boolean share​(@Nullable
                                    android.content.Context context,
                                    @Nullable
                                    java.lang.String title,
                                    @Nullable
                                    java.lang.String message,
                                    @Nullable
                                    android.net.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 retrieve the resources.
        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:
        Intent.ACTION_SEND
      • share

        public static boolean share​(@Nullable
                                    android.content.Context context,
                                    @Nullable
                                    java.lang.String title,
                                    @Nullable
                                    java.lang.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 retrieve the resources.
        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:
        Intent.ACTION_SEND
      • shareApp

        public static boolean shareApp​(@Nullable
                                       android.content.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 retrieve the resources.
        Returns:
        true on successful operation.
        See Also:
        share(Context, String, String)
      • viewUrl

        public static boolean viewUrl​(@Nullable
                                      android.content.Context context,
                                      @Nullable
                                      java.lang.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 retrieve the resources.
        url - The web or app link to open.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_VIEW
      • viewInGooglePlay

        public static boolean viewInGooglePlay​(@Nullable
                                               android.content.Context context,
                                               @NonNull
                                               java.lang.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 retrieve the resources.
        packageName - Application package name to build the search query.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_VIEW
      • rateApp

        public static boolean rateApp​(@Nullable
                                      android.content.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 retrieve the resources.
        Returns:
        true on successful operation.
        See Also:
        viewInGooglePlay(Context, String)
      • moreApps

        public static boolean moreApps​(@Nullable
                                       android.content.Context context,
                                       @NonNull
                                       java.lang.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 retrieve the resources.
        publisher - The publisher name to build the search query.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_VIEW
      • email

        public static boolean email​(@Nullable
                                    android.content.Context context,
                                    @NonNull
                                    java.lang.String[] emails,
                                    @Nullable
                                    java.lang.String subject,
                                    @Nullable
                                    java.lang.String text)
        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 retrieve the resources.
        emails - The email ids of the developer.
        subject - The optional email subject.
        text - The optional email text.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_SENDTO, MailTo.MAILTO_SCHEME
      • email

        public static boolean email​(@Nullable
                                    android.content.Context context,
                                    @NonNull
                                    java.lang.String email,
                                    @Nullable
                                    java.lang.String subject,
                                    @Nullable
                                    java.lang.String text)
        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 retrieve the resources.
        email - The email id of the developer.
        subject - The optional email subject.
        text - The optional email text.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_SENDTO, MailTo.MAILTO_SCHEME
      • report

        public static boolean report​(@Nullable
                                     android.content.Context context,
                                     @Nullable
                                     java.lang.String appName,
                                     @NonNull
                                     java.lang.String email,
                                     java.lang.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 retrieve the resources.
        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:
        Intent.ACTION_SENDTO, MailTo.MAILTO_SCHEME
      • report

        public static boolean report​(@Nullable
                                     android.content.Context context,
                                     @Nullable
                                     java.lang.String appName,
                                     @NonNull
                                     java.lang.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 retrieve the resources.
        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:
        report(Context, String, String, Boolean)
      • isEmailExists

        public static boolean isEmailExists​(@Nullable
                                            android.content.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
                                          android.content.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
                                                     android.content.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
                                               android.content.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:
        isGMSExists(Context), isGoogleFeedbackExists(Context)
      • feedback

        public static boolean feedback​(@Nullable
                                       android.content.Context context,
                                       @Nullable
                                       java.lang.String appName,
                                       @NonNull
                                       java.lang.String email,
                                       int reportType,
                                       @Nullable
                                       android.app.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 retrieve the resources.
        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:
        ApplicationErrorReport
      • feedback

        public static boolean feedback​(@Nullable
                                       android.content.Context context,
                                       @Nullable
                                       java.lang.String appName,
                                       @NonNull
                                       java.lang.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 retrieve the resources.
        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:
        ApplicationErrorReport, ApplicationErrorReport.TYPE_NONE