Class DynamicIntentUtils
java.lang.Object
com.pranavpandey.android.dynamic.util.DynamicIntentUtils
Helper class to perform
Intent
operations.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
addImmutableFlag
(int flags) Add immutable flag to thePendingIntent
.static int
addMutabilityFlag
(int flags, boolean mutable) Add mutability flag to thePendingIntent
.static int
addMutableFlag
(int flags) Add mutable flag to thePendingIntent
.static Intent
getActivityIntent
(Context context, Class<?> clazz) Returns the activity intent for the supplied class.static Intent
getActivityIntentForResult
(Context context, Class<?> clazz) Returns the activity intent for the supplied class to get the result.static Intent
Returns the intent for the supplied class.static Intent
Returns the intent for the supplied class and flags.static Intent
getMatrixCaptureResultIntent
(Context context) Returns the intent to capture the matrix result.static Uri
getStreamOrData
(Intent intent, String action) Returns the intent stream or data URI according to the supplied action.static boolean
isActivityResolved
(Context context, Intent intent) Checks whether the supplied intent has at least one activity to handle it.static boolean
isFilePicker
(Context context) Checks the availability of a file picker.static boolean
isFilePicker
(Context context, boolean downloads) Checks the availability of a file picker.static boolean
isFilePicker
(Context context, String mimeType) Checks the availability of a file picker.static boolean
isFilePicker
(Context context, String mimeType, boolean downloads) Checks the availability of a file picker.static boolean
isMatrixCaptureResult
(Context context) Checks whether the device can capture the matrix result.static boolean
viewIntent
(Context context, Intent intent) View any Intent in the available app or browser.
-
Field Details
-
ACTION_MATRIX_CAPTURE_RESULT
Action to capture the matrix result.- See Also:
-
EXTRA_MATRIX_DATA
Intent extra key for the matrix data.- See Also:
-
EXTRA_MATRIX_FORMAT
Intent extra key for the matrix format.- See Also:
-
-
Constructor Details
-
DynamicIntentUtils
public DynamicIntentUtils()
-
-
Method Details
-
getIntent
@NonNull public static Intent getIntent(@Nullable Context context, @Nullable 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:
-
getIntent
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:
-
getActivityIntent
@NonNull public static Intent getActivityIntent(@Nullable Context context, @Nullable Class<?> clazz) Returns the activity intent for the supplied class.- 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.
- See Also:
-
getActivityIntentForResult
@NonNull public static Intent getActivityIntentForResult(@Nullable Context context, @Nullable 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:
-
getStreamOrData
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:
-
isActivityResolved
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:
-
isFilePicker
public static boolean isFilePicker(@Nullable Context context, @Nullable String mimeType, boolean downloads) Checks the availability of a file picker.- Parameters:
context
- The context to get the package manager.mimeType
- The mime type for the file.downloads
-true
to consider the download location on older API levels.- Returns:
true
if a file picker is present.- See Also:
-
isFilePicker
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
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
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:
-
addMutabilityFlag
public static int addMutabilityFlag(int flags, boolean mutable) Add mutability flag to thePendingIntent
.- Parameters:
flags
- The flags to be updated.mutable
-true
to make it mutable.- Returns:
- The updated flags.
- See Also:
-
addMutableFlag
public static int addMutableFlag(int flags) Add mutable flag to thePendingIntent
.- Parameters:
flags
- The flags to be updated.- Returns:
- The updated flags.
- See Also:
-
addImmutableFlag
public static int addImmutableFlag(int flags) Add immutable flag to thePendingIntent
.- Parameters:
flags
- The flags to be updated.- Returns:
- The updated flags.
- See Also:
-
viewIntent
View any Intent in the available app or browser.Use
queries
tag forIntent.ACTION_VIEW
with appropriatescheme(s)
inAndroidManifest
to support API 30.- Parameters:
context
- The context to be used.intent
- The intent to view.- Returns:
true
on successful operation.- See Also:
-
isMatrixCaptureResult
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:
-
getMatrixCaptureResultIntent
Returns the intent to capture the matrix result.- Parameters:
context
- The context to get the intent.- Returns:
- The intent to capture the matrix result.
- See Also:
-