Class DynamicDeviceUtils
- java.lang.Object
-
- com.pranavpandey.android.dynamic.util.DynamicDeviceUtils
-
public class DynamicDeviceUtils extends java.lang.ObjectHelper class to detect device specific features like Telephony, etc.
-
-
Constructor Summary
Constructors Constructor Description DynamicDeviceUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetDate(android.content.Context context, long milliSeconds)Retrieve a date and time string from milliSeconds according to the system settings.static java.lang.StringgetDateWithSeparator(long milliSeconds)Retrieve a date and time string with separatorsyyyy-MM-dd-HH-mm-ssfrom the supplied milliSeconds.static booleanhasTelephony(android.content.Context context)Detects the telephony feature by usingPackageManager.static booleanisXiaomiMIUI(android.content.Context context)Checks whether the device has MIUI services installed.static voidvibrate(android.content.Context context, long duration)Vibrate device for the supplied duration.
-
-
-
Method Detail
-
vibrate
@RequiresPermission("android.permission.VIBRATE") public static void vibrate(@Nullable android.content.Context context, long duration)Vibrate device for the supplied duration.- Parameters:
context- The context to get the vibrator service.duration- The duration in milliseconds.- See Also:
Vibrator.vibrate(VibrationEffect),VibrationEffect.createOneShot(long, int),Vibrator.vibrate(long)
-
hasTelephony
public static boolean hasTelephony(@NonNull android.content.Context context)Detects the telephony feature by usingPackageManager.- Parameters:
context- The context to get the package manager.- Returns:
trueif the device has telephony feature.- See Also:
PackageManager.hasSystemFeature(String),PackageManager.FEATURE_TELEPHONY
-
getDate
@NonNull public static java.lang.String getDate(@NonNull android.content.Context context, long milliSeconds)Retrieve a date and time string from milliSeconds according to the system settings.- Parameters:
context- The context to retrieve system date and time format.milliSeconds- The millis to be converted into date and time.- Returns:
- The formatted date according to system settings.
- See Also:
Date
-
getDateWithSeparator
@NonNull public static java.lang.String getDateWithSeparator(long milliSeconds)
Retrieve a date and time string with separatorsyyyy-MM-dd-HH-mm-ssfrom the supplied milliSeconds.- Parameters:
milliSeconds- The millis to be converted into date and time.- Returns:
- The formatted date and time string with separators.
- See Also:
SimpleDateFormat
-
isXiaomiMIUI
public static boolean isXiaomiMIUI(@NonNull android.content.Context context)Checks whether the device has MIUI services installed.- Parameters:
context- The context to resolve the activities.- Returns:
trueif the device has MIUI services installed.
-
-