Class DynamicDeviceUtils


  • public class DynamicDeviceUtils
    extends java.lang.Object
    Helper class to detect device specific features like Telephony, etc.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getDate​(android.content.Context context, long milliSeconds)
      Retrieve a date and time string from milliSeconds according to the system settings.
      static java.lang.String getDateWithSeparator​(long milliSeconds)
      Retrieve a date and time string with separators yyyy-MM-dd-HH-mm-ss from the supplied milliSeconds.
      static boolean hasTelephony​(android.content.Context context)
      Detects the telephony feature by using PackageManager.
      static boolean isXiaomiMIUI​(android.content.Context context)
      Checks whether the device has MIUI services installed.
      static void vibrate​(android.content.Context context, long duration)
      Vibrate device for the supplied duration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DynamicDeviceUtils

        public DynamicDeviceUtils()
    • 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 using PackageManager.
        Parameters:
        context - The context to get the package manager.
        Returns:
        true if 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 separators yyyy-MM-dd-HH-mm-ss from 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:
        true if the device has MIUI services installed.