1. 隐藏软键盘
private void hideKeyboard() { final Activity activity = getActivity(); if (activity != null) { View view = activity.getCurrentFocus(); InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
2. 判断有没有实体导航键,HOME BACK RECENT
一般是去看property qemu.hw.mainkeys
可以用adb shell getprop或者在BSP里使用SystemProperties去查看
3. 获取Internal和外部SD卡容量大小:
StorageManager mStorageManager;mStorageManager = context.getSystemService(StorageManager.class);final Listvolumes = mStorageManager.getVolumes(); Collections.sort(volumes, VolumeInfo.getDescriptionComparator()); for (VolumeInfo vol : volumes) { if (vol.getType() == VolumeInfo.TYPE_PRIVATE) { //Internal storage final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol, sTotalInternalStorage); } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) { // SD card } }public static long getTotalSize(VolumeInfo info, long totalInternalStorage) { final Context context = AppGlobals.getInitialApplication(); final StorageStatsManager stats = context.getSystemService(StorageStatsManager.class); try { return stats.getTotalBytes(info.getFsUuid()); } catch (IOException e) { Log.w(TAG, e); return 0; } }
4. frameworks修改 支持屏幕旋转180度
frameworks/base/core/res/res/values/config.xml
true
参考 https://blog.csdn.net/Aaron121314/article/details/78235938
5. 启用/禁用锁屏旋转
修改 frameworks/base/core/res/res/values/config.xml
false
去使用这个config的位置在 frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
private boolean shouldEnableKeyguardScreenRotation() { Resources res = mContext.getResources(); return SystemProperties.getBoolean("lockscreen.rot_override", false) || res.getBoolean(R.bool.config_enableLockScreenRotation); }