-
public class AndroidContextsUtility context definitions.
-
-
Method Summary
Modifier and Type Method Description static booleanhasPermission(Context ctxt, String perm)Test whether a permission has been granted. static booleanhasAllPermissions(Context ctxt, Array<String> perms)Test whether all permissions have been granted. static booleanhasAnyPermissions(Context ctxt, Array<String> perms)Test whether any permissions have been granted. static booleanhasSystemFeature(Context ctxt, String feat)Test whether a system feature is present. static <T> TsystemServiceOf(Context ctxt, Class<T> type, String name)Retrieve system service from a context. static <T, R> RwithSystemService(Context ctxt, Class<T> type, String name, Function<T, R> op)Apply operation on system service, if available. static <T, R> RwithSystemService(Context ctxt, Class<T> type, String name, Function<T, R> op, R dfl)Apply operation on system service, if available, or return default value. static StringcurrentProcessName(Context ctxt)Retrieve name of executing process. -
-
Method Detail
-
hasPermission
static boolean hasPermission(Context ctxt, String perm)
Test whether a permission has been granted.
- Parameters:
ctxt- context to testperm- permission to test for
-
hasAllPermissions
static boolean hasAllPermissions(Context ctxt, Array<String> perms)
Test whether all permissions have been granted.
- Parameters:
ctxt- context to testperms- permissions to test for
-
hasAnyPermissions
static boolean hasAnyPermissions(Context ctxt, Array<String> perms)
Test whether any permissions have been granted.
- Parameters:
ctxt- context to testperms- permissions to test for
-
hasSystemFeature
static boolean hasSystemFeature(Context ctxt, String feat)
Test whether a system feature is present.
- Parameters:
ctxt- context to testfeat- feature to test for
-
systemServiceOf
static <T> T systemServiceOf(Context ctxt, Class<T> type, String name)
Retrieve system service from a context.
- Parameters:
ctxt- context to retrieve fromtype- service type classname- service name
-
withSystemService
static <T, R> R withSystemService(Context ctxt, Class<T> type, String name, Function<T, R> op)
Apply operation on system service, if available.
- Parameters:
ctxt- context to retrieve fromtype- service type classname- service nameop- operation to perform
-
withSystemService
static <T, R> R withSystemService(Context ctxt, Class<T> type, String name, Function<T, R> op, R dfl)
Apply operation on system service, if available, or return default value.
- Parameters:
ctxt- context to retrieve fromtype- service type classname- service nameop- operation to performdfl- default value to return
-
currentProcessName
static String currentProcessName(Context ctxt)
Retrieve name of executing process.
- Parameters:
ctxt- context to retrieve from
-
-
-
-