- 代码如下
/** * AndroidUSBCamera-master * Created by lzw on 2018/6/20. 10:53:22 * 邮箱:[email protected] * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class ShieldUtil { public static final String STATUS_BAR_SERVICE = "statusbar"; public static final String CLASS_STATUS_BAR_MANAGER = "android.app.StatusBarManager"; public static final String METHOD_DISABLE = "disable"; public static final String METHOD_ENABLE = "enable"; public static void hideKeys(Context context){ try { @SuppressLint("WrongConstant") Object service = context.getSystemService(STATUS_BAR_SERVICE); Class<?> statusBarManager = Class.forName(CLASS_STATUS_BAR_MANAGER); Method disable = statusBarManager.getMethod(METHOD_DISABLE, int.class); // disable.invoke(service, 0x00200000); // 为View.STATUS_BAR_DISABLE_HOME 的值 // disable.invoke(service, 0x00400000); // 为View.STATUS_BAR_DISABLE_BACK 的值 disable.invoke(service, 0x00200000|0x01000000); // 为View.STATUS_BAR_DISABLE_RECENT的值 } catch (Exception e) { e.printStackTrace(); } } public static void showKeys(Context context){ try { @SuppressLint("WrongConstant") Object service = context.getSystemService(STATUS_BAR_SERVICE); Class<?> statusBarManager = Class.forName(CLASS_STATUS_BAR_MANAGER); Method disable = statusBarManager.getMethod(METHOD_DISABLE, int.class); disable.invoke(service, 0x00000000|0x00000000); // 为View.STATUS_BAR_DISABLE_RECENT的值 } catch (Exception e) { e.printStackTrace(); } } }
- 注意:只能在有系统权限下使用,也就是在AndroidManifest.xml里面有
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:sharedUserId="android.uid.system" package="com.jiangdg.usbcamera">
- 需要有权限
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
- 所以这就决定了只能再自己有源码不是定制android系统的设备上有效果
android虚拟键盘disable与enable
猜你喜欢
转载自www.cnblogs.com/endian11/p/9202929.html
今日推荐
周排行