Class DynamicIntentUtils
- java.lang.Object
-
- com.pranavpandey.android.dynamic.util.DynamicIntentUtils
-
public class DynamicIntentUtils extends java.lang.ObjectHelper class to performIntentoperations.
-
-
Constructor Summary
Constructors Constructor Description DynamicIntentUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intaddImmutableFlag(int flags)Add immutable flag to thePendingIntent.static intaddMutabilityFlag(int flags, boolean mutable)Add mutability flag to thePendingIntent.static intaddMutableFlag(int flags)Add mutable flag to thePendingIntent.static android.content.IntentgetActivityIntent(android.content.Context context, java.lang.Class<?> clazz)Returns the activity intent for the supplied class.static android.content.IntentgetActivityIntentForResult(android.content.Context context, java.lang.Class<?> clazz)Returns the activity intent for the supplied class to get the result.static android.content.IntentgetIntent(android.content.Context context, java.lang.Class<?> clazz)Returns the intent for the supplied class.static android.content.IntentgetIntent(android.content.Context context, java.lang.Class<?> clazz, int flags)Returns the intent for the supplied class and flags.static android.net.UrigetStreamOrData(android.content.Intent intent, java.lang.String action)Returns the intent stream or data URI according to the supplied action.static booleanisActivityResolved(android.content.Context context, android.content.Intent intent)Checks whether the supplied intent has at least one activity to handle it.static booleanisFilePicker(android.content.Context context)Checks the availability of a file picker.static booleanisFilePicker(android.content.Context context, boolean downloads)Checks the availability of a file picker.static booleanviewIntent(android.content.Context context, android.content.Intent intent)View any Intent in the available app or browser.
-
-
-
Method Detail
-
getIntent
@NonNull public static android.content.Intent getIntent(@NonNull android.content.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 android.content.Intent getIntent(@NonNull android.content.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)
-
getActivityIntent
@NonNull public static android.content.Intent getActivityIntent(@NonNull android.content.Context context, @Nullable java.lang.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:
Intent.FLAG_ACTIVITY_NEW_TASK,Intent.FLAG_ACTIVITY_CLEAR_TOP,getIntent(Context, Class, int)
-
getActivityIntentForResult
@NonNull public static android.content.Intent getActivityIntentForResult(@NonNull android.content.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 android.net.Uri getStreamOrData(@Nullable android.content.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 android.content.Context context, @Nullable android.content.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:
trueif the supplied intent has at least one activity to handle it.- See Also:
PackageManager.resolveActivity(Intent, int)
-
isFilePicker
public static boolean isFilePicker(@Nullable android.content.Context context, boolean downloads)Checks the availability of a file picker.- Parameters:
context- The context to get the package manager.downloads-trueto consider the download location on older API levels.- Returns:
trueif a file picker is present.- See Also:
isActivityResolved(Context, Intent),Intent.ACTION_GET_CONTENT,Intent.ACTION_OPEN_DOCUMENT,Environment.getExternalStoragePublicDirectory(String),Environment.DIRECTORY_DOWNLOADS
-
isFilePicker
public static boolean isFilePicker(@Nullable android.content.Context context)Checks the availability of a file picker.- Parameters:
context- The context to get the package manager.- Returns:
trueif a file picker is present.- See Also:
isFilePicker(Context)
-
addMutabilityFlag
public static int addMutabilityFlag(int flags, boolean mutable)Add mutability flag to thePendingIntent.- Parameters:
flags- The flags to be updated.mutable-trueto make it mutable.- Returns:
- The updated flags.
- See Also:
PendingIntent.FLAG_IMMUTABLE
-
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:
addMutabilityFlag(int, boolean)
-
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:
addMutabilityFlag(int, boolean),PendingIntent.FLAG_IMMUTABLE
-
viewIntent
public static boolean viewIntent(@Nullable android.content.Context context, @Nullable android.content.Intent intent)View any Intent in the available app or browser.Use
queriestag forIntent.ACTION_VIEWwith appropriatescheme(s)inAndroidManifestto support API 30.- Parameters:
context- The context to retrieve the resources.intent- The intent to view.- Returns:
trueon successful operation.- See Also:
Intent.ACTION_VIEW
-
-