This article shares the specific code of Android system tool class for your reference. The specific content is as follows
System Tools
public class systemUtil { //Hide the virtual keybar at the bottom of the ipad @RequiresApi(api = Build.VERSION_CODES.KITKAT) public static void closeBottomBar(Activity activity){ Window _window = (); params = _window.getAttributes(); = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE; _window.setAttributes(params); } //The soft keyboard does not pop up automatically public static void softInputMode(Activity activity){ ().setSoftInputMode( .SOFT_INPUT_ADJUST_RESIZE | .SOFT_INPUT_STATE_HIDDEN); } //Keep the screen on public static void screenLightUp(Activity activity){ ().addFlags(.FLAG_KEEP_SCREEN_ON); } //Get screen resolution public static int[] defaultDisplay(Activity activity){ int[] pixels = new int[2]; DisplayMetrics dm = new DisplayMetrics(); ().getDefaultDisplay().getMetrics(dm); pixels[0]=; pixels[1]=; return pixels; } //Get the Android system version public static String getSystemVersion() { return ; } //Get the device model public static String getSystemModel() { return ; } //Get the IMEI identification number //Required permissions <uses-permission android:name=".READ_PHONE_STATE" /> @SuppressLint("MissingPermission") public static String getIMEI(Activity activity) { // Dynamic permissions added to the system above 6.0 if ((activity, .READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { (activity, new String[]{.READ_PHONE_STATE},1); } TelephonyManager tm = (TelephonyManager) (Activity.TELEPHONY_SERVICE); return (); } //Get the current language of the system public static String getSystemLanguage() { return ().getLanguage(); } //Get the power of the equipment @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static int getBattery(Context context){ BatteryManager batteryManager = (BatteryManager)(BATTERY_SERVICE); return (BatteryManager.BATTERY_PROPERTY_CAPACITY); } //Get the available size of device memory (GB) public static String getRomAvailableSize(Context context) { File path = (); StatFs stat = new StatFs(()); long blockSize = (); long availableBlocks = (); return (context, blockSize * availableBlocks); } //Get the total amount of available device memory (GB) public static String getRomTotalSize(Context context) { File path = (); StatFs stat = new StatFs(()); long blockSize = (); long totalBlocks = (); return (context, blockSize * totalBlocks); } //Get the total available size of the SD card public static String getSDTotalSize(Context context) { File path = (); StatFs stat = new StatFs(()); long blockSize = (); long totalBlocks = (); return (context, blockSize * totalBlocks); } //Get the available size of the SD card private String getSDAvailableSize(Context context) { File path = (); StatFs stat = new StatFs(()); long blockSize = (); long availableBlocks = (); return (context, blockSize * availableBlocks); } //Restart the device private void restartDevices() { String cmd = "su -c reboot"; try { ().exec(cmd); } catch (IOException e) { ("restart","Insufficient permissions"); } } }
System-related permissions
//Write to external storage.WRITE_EXTERNAL_STORAGE,Allow writing to external storage //Read external storage.READ_EXTERNAL_STORAGE,Allows reading of external storage //Read the system log.READ_LOGS,Read the system's underlying log //Read the text message content.READ_SMS,Read text message content //vibration,Vibration allowed //Restart the device,Allow the program to restart the device //Installing the application.INSTALL_PACKAGES,Allow the program to install the application //Modify the sound.MODIFY_AUDIO_SETTINGS,Modify sound settings information //recording.RECORD_AUDIO,Record sound through a cell phone or headset with a microphone //Use flash,Allow access to flash //Access the network,Access to the network connection,PossibleGPRSflow //Change wifi status.CHANGE_WIFI_STATE,Openwifi,Changewifistate //Get WiFi status.ACCESS_WIFI_STATE,Get the current oneWiFi接入的state以及WLANHot information //Get network status.ACCESS_NETWORK_STATE,获取网络信息state,If the current network connection is valid //Photo permission,Allow access to the camera for taking photos //Use Bluetooth,Allow the program to connect to paired Bluetooth devices //Battery status.BATTERY_STATS,允许应用程序获取电池state的权限
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.