android虛擬鍵盤disable與enable

來源:互聯網
上載者:User

標籤: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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.