Class DynamicDeviceUtils
java.lang.Object
com.pranavpandey.android.dynamic.util.DynamicDeviceUtils
Helper class to detect device specific features like Telephony, etc.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
connectWifi
(Context context, String ssid, String password, String encryption, boolean hidden) Try to save the Wi-Fi configuration according to the supplied parameters.static String
Retrieve a date and time string from milliSeconds according to the system settings.static String
getDateWithSeparator
(long milliSeconds) Retrieve a date and time string with separatorsyyyy-MM-dd-HH-mm-ss
from the supplied milliSeconds.static WifiConfiguration
getWifiConfiguration
(String ssid, String password, String encryption, boolean hidden) Returns the Wi-Fi configuration according to the supplied parameters.static boolean
hasCameraFeature
(Context context) Checks whether the device has camera feature.static boolean
hasFlashlightFeature
(Context context) Checks whether the device has flashlight feature.static boolean
hasHingeFeature
(Context context) Detects the hinge sensor feature by usingPackageManager
.static boolean
hasSystemFeature
(Context context, String feature) Checks whether the device has a system feature.static boolean
hasTelephony
(Context context) Detects the telephony feature by usingPackageManager
.static boolean
Checks whether the device has a One UI version installed.static boolean
isXiaomiMIUI
(Context context) Checks whether the device has MIUI services installed.static void
Vibrate device for the supplied duration.
-
Field Details
-
PATTERN_WEP
Pattern for the WEP encryption. -
PATTERN_WPA
Pattern for the WPA encryption.
-
-
Constructor Details
-
DynamicDeviceUtils
public DynamicDeviceUtils()
-
-
Method Details
-
getWifiConfiguration
@Nullable public static WifiConfiguration getWifiConfiguration(@Nullable String ssid, @Nullable String password, @Nullable String encryption, boolean hidden) Returns the Wi-Fi configuration according to the supplied parameters.- Parameters:
ssid
- The network ssid to be used.password
- The password to be used.encryption
- The encryption method to be used.hidden
-true
if the network is hidden.- Returns:
- The Wi-Fi configuration according to the supplied parameters.
- See Also:
-
connectWifi
@RequiresPermission(allOf={"android.permission.ACCESS_WIFI_STATE","android.permission.CHANGE_WIFI_STATE"}) public static boolean connectWifi(@Nullable Context context, @Nullable String ssid, @Nullable String password, @Nullable String encryption, boolean hidden) Try to save the Wi-Fi configuration according to the supplied parameters.- Parameters:
context
- The context to used.ssid
- The network ssid to be used.password
- The password to be used.encryption
- The encryption method to be used.hidden
-true
if the network is hidden.- Returns:
- {code true} on successful operation.
- See Also:
-
hasSystemFeature
Checks whether the device has a system feature.- Parameters:
context
- The context to be used.feature
- The feature to be checked.- Returns:
true
if the device has the system feature.
-
hasCameraFeature
Checks whether the device has camera feature.- Parameters:
context
- The context to be used.- Returns:
true
if the device has camera feature.- See Also:
-
hasFlashlightFeature
Checks whether the device has flashlight feature.- Parameters:
context
- The context to be used.- Returns:
true
if the device has flashlight feature.- See Also:
-
hasTelephony
Detects the telephony feature by usingPackageManager
.- Parameters:
context
- The context to get the package manager.- Returns:
true
if the device has telephony feature.- See Also:
-
hasHingeFeature
Detects the hinge sensor feature by usingPackageManager
.- Parameters:
context
- The context to get the package manager.- Returns:
true
if the device has hinge sensor feature feature.- See Also:
-
vibrate
@RequiresPermission("android.permission.VIBRATE") public static void vibrate(@Nullable 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:
-
getDate
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:
-
getDateWithSeparator
Retrieve a date and time string with separatorsyyyy-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:
-
isSamsungOneUI
public static boolean isSamsungOneUI()Checks whether the device has a One UI version installed.- Returns:
true
if the device has a One UI version installed.
-
isXiaomiMIUI
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.
-