標籤:try pac apk ted xmlns exception hide share get
- 代碼如下
/** * 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