当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.KEYCODE_POWER属性代码示例

本文整理汇总了Java中android.view.KeyEvent.KEYCODE_POWER属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_POWER属性的具体用法?Java KeyEvent.KEYCODE_POWER怎么用?Java KeyEvent.KEYCODE_POWER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_POWER属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispatchKeyEvent

/**
 * 屏蔽按键 然而并没什么用。。。
 * @param keyEvent 按键事件
 * @return 是否已经处理过按键
 */
@Override
public boolean dispatchKeyEvent(@NonNull KeyEvent keyEvent) {
    switch (keyEvent.getKeyCode()) {
        case KeyEvent.KEYCODE_POWER:
        case KeyEvent.KEYCODE_HOME:
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_CALL:
        case KeyEvent.KEYCODE_SYM:
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_STAR:
            return true;
    }

    return super.dispatchKeyEvent(keyEvent);
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:21,代码来源:AlarmNoticeActivity.java

示例2: onKeyEvent

@Override
protected boolean onKeyEvent(KeyEvent event) {
    int keycode = event.getKeyCode();
    if (keycode == KeyEvent.KEYCODE_POWER) {
        return false;
    }
    boolean enable_keyblock = mSp.getBoolean(Config.ENABLED_KEYBLOCK, false);
    if (closeAdvancedFunction) {
        return enable_keyblock;
    }
    if (event.getAction() == ACTION_DOWN) {
        if (keycode == KeyEvent.KEYCODE_BACK) {
            if (mSp.getBoolean(Config.DOUBLE_CLICK_EXIT, false) && enable_keyblock) {
                long nowTime = System.currentTimeMillis();
                if (nowTime - backClickTime <= 700) {
                    CloseBlock();
                    backClickTime = 0;
                    return true;
                } else {
                    backClickTime = nowTime;
                }
            }
        }
        if (mSp.getBoolean(Config.DISPLAY_KEYCODE, false)) {
            Toast.makeText(this, "Keycode: " + keycode, Toast.LENGTH_SHORT).show();
        }
    }
    if (enable_keyblock) {
        if (mSp.getBoolean(Config.ENABLED_VOLUME_KEY, false) && (keycode == KeyEvent.KEYCODE_VOLUME_UP || keycode == KeyEvent.KEYCODE_VOLUME_MUTE || keycode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
            return false;
        }
        if (mSp.getBoolean(Config.ENABLED_CUSTOM_KEYCODE, false)) {
            String[] sourceStrArray = mSp.getString(Config.CUSTOM_KEYCODE, "").split(" ");
            Arrays.sort(sourceStrArray);
            int index = Arrays.binarySearch(sourceStrArray, String.valueOf(keycode));
            boolean isDisabled = index >= 0;
            if (event.getAction() == ACTION_UP && mSp.getBoolean(Config.DISPLAY_KEYCODE, false)) {
                if (isDisabled) {
                    Toast.makeText(this, "KeyCode: " + keycode + " " + getString(R.string.has_disabled), Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(this, "KeyCode: " + keycode, Toast.LENGTH_SHORT).show();
                }
            }
            return isDisabled;
        }
        return true;
    } else {
        return false;
    }
}
 
开发者ID:XFY9326,项目名称:KeyBlocker,代码行数:50,代码来源:KeyBlockService.java

示例3: showPowerMenu

@Override
protected void showPowerMenu(Context context) {
    Instrumentation mInst = new Instrumentation();
    KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POWER);
    mInst.sendKeySync(keyEvent);
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:6,代码来源:BtnScreenOff.java


注:本文中的android.view.KeyEvent.KEYCODE_POWER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。