Class DynamicIntentUtils


  • public class DynamicIntentUtils
    extends java.lang.Object
    Helper class to perform Intent operations.
    • Field Detail

      • ACTION_MATRIX_CAPTURE_RESULT

        public static final java.lang.String ACTION_MATRIX_CAPTURE_RESULT
        Action to capture the matrix result.
        See Also:
        Constant Field Values
      • EXTRA_MATRIX_DATA

        public static final java.lang.String EXTRA_MATRIX_DATA
        Intent extra key for the matrix data.
        See Also:
        Constant Field Values
      • EXTRA_MATRIX_FORMAT

        public static final java.lang.String EXTRA_MATRIX_FORMAT
        Intent extra key for the matrix format.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DynamicIntentUtils

        public DynamicIntentUtils()
    • Method Detail

      • getIntent

        @NonNull
        public static Intent getIntent​(@Nullable
                                       Context context,
                                       @Nullable
                                       java.lang.Class<?> clazz,
                                       int flags)
        Returns the intent for the supplied class and flags.
        Parameters:
        context - The context to create the intent.
        clazz - The class for which the intent to be created.
        flags - intent flags to be set.
        Returns:
        The intent for the supplied class and flags.
        See Also:
        Intent.setComponent(ComponentName), Intent.addFlags(int)
      • getIntent

        @NonNull
        public static Intent getIntent​(@Nullable
                                       Context context,
                                       @Nullable
                                       java.lang.Class<?> clazz)
        Returns the intent for the supplied class.
        Parameters:
        context - The context to create the intent.
        clazz - The class for which the intent to be created.
        Returns:
        The intent for the supplied class.
        See Also:
        getIntent(Context, Class, int)
      • getActivityIntentForResult

        @NonNull
        public static Intent getActivityIntentForResult​(@Nullable
                                                        Context context,
                                                        @Nullable
                                                        java.lang.Class<?> clazz)
        Returns the activity intent for the supplied class to get the result.
        Parameters:
        context - The context to create the intent.
        clazz - The activity class for which the intent to be created.
        Returns:
        The activity intent for the supplied class to get the result.
        See Also:
        Intent.FLAG_ACTIVITY_CLEAR_TOP, getIntent(Context, Class, int)
      • getStreamOrData

        @Nullable
        public static Uri getStreamOrData​(@Nullable
                                          Intent intent,
                                          @NonNull
                                          java.lang.String action)
        Returns the intent stream or data URI according to the supplied action.
        Parameters:
        intent - The intent to get the URI.
        action - The action to return stream URI.
        Returns:
        The intent URI according to the stream or data.
        See Also:
        Intent.EXTRA_STREAM, Intent.getData()
      • isActivityResolved

        public static boolean isActivityResolved​(@Nullable
                                                 Context context,
                                                 @Nullable
                                                 Intent intent)
        Checks whether the supplied intent has at least one activity to handle it.
        Parameters:
        context - The context to get the package manager.
        intent - The intent to be resolved.
        Returns:
        true if the supplied intent has at least one activity to handle it.
        See Also:
        PackageManager.resolveActivity(Intent, int)
      • isFilePicker

        public static boolean isFilePicker​(@Nullable
                                           Context context,
                                           @Nullable
                                           java.lang.String mimeType)
        Checks the availability of a file picker.
        Parameters:
        context - The context to get the package manager.
        mimeType - The mime type for the file.
        Returns:
        true if a file picker is present.
        See Also:
        isFilePicker(Context, String, boolean)
      • isFilePicker

        public static boolean isFilePicker​(@Nullable
                                           Context context,
                                           boolean downloads)
        Checks the availability of a file picker.
        Parameters:
        context - The context to get the package manager.
        downloads - true to consider the download location on older API levels.
        Returns:
        true if a file picker is present.
        See Also:
        isFilePicker(Context, String, boolean)
      • isFilePicker

        public static boolean isFilePicker​(@Nullable
                                           Context context)
        Checks the availability of a file picker.
        Parameters:
        context - The context to get the package manager.
        Returns:
        true if a file picker is present.
        See Also:
        isFilePicker(Context, String, boolean)
      • addMutabilityFlag

        public static int addMutabilityFlag​(int flags,
                                            boolean mutable)
        Add mutability flag to the PendingIntent.
        Parameters:
        flags - The flags to be updated.
        mutable - true to make it mutable.
        Returns:
        The updated flags.
        See Also:
        PendingIntent.FLAG_IMMUTABLE
      • addMutableFlag

        public static int addMutableFlag​(int flags)
        Add mutable flag to the PendingIntent.
        Parameters:
        flags - The flags to be updated.
        Returns:
        The updated flags.
        See Also:
        addMutabilityFlag(int, boolean)
      • viewIntent

        public static boolean viewIntent​(@Nullable
                                         Context context,
                                         @Nullable
                                         Intent intent)
        View any Intent in the available app or browser.

        Use queries tag for Intent.ACTION_VIEW with appropriate scheme(s) in AndroidManifest to support API 30.

        Parameters:
        context - The context to be used.
        intent - The intent to view.
        Returns:
        true on successful operation.
        See Also:
        Intent.ACTION_VIEW
      • isMatrixCaptureResult

        public static boolean isMatrixCaptureResult​(@Nullable
                                                    Context context)
        Checks whether the device can capture the matrix result.
        Parameters:
        context - The context to get the package manager.
        Returns:
        true if the device has at least one activity to capture the matrix result.
        See Also:
        isActivityResolved(Context, Intent), ACTION_MATRIX_CAPTURE_RESULT