Java Code Examples for android.view.KeyEvent#KEYCODE_APP_SWITCH

The following examples show how to use android.view.KeyEvent#KEYCODE_APP_SWITCH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Multiwii-Remote with Apache License 2.0 8 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(app.PreventExitWhenFlying && rc.isFlying() && (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_APP_SWITCH || event.getKeyCode() == KeyEvent.KEYCODE_HOME))
{
	Utilities.showToast("Detected flying. Please put throttle under 1100.", this);
	return true;
}
	if (event.getAction() == KeyEvent.ACTION_DOWN)
		switch (event.getKeyCode()) {
		case KeyEvent.KEYCODE_VOLUME_UP:
			rc.adjustRcValue(-1);
			return true;
		case KeyEvent.KEYCODE_VOLUME_DOWN:
			rc.adjustRcValue(1);
			return true;
		case KeyEvent.KEYCODE_SEARCH:
			app.setManualModeOn(!app.getManualMode());
			return true;
		}
	return super.dispatchKeyEvent(event);
}
 
Example 2
Source File: KeyPressedTipViewController.java    From timecat with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
        String reason = intent.getStringExtra(SYSTEM_REASON);
        if (TextUtils.equals(reason, SYSTEM_HOME_KEY)) {
            //表示按了home键,程序到了后台
            if (currentKeyCode == KeyEvent.KEYCODE_HOME && isLongPressedHome) {
                isLongPressedHome = false;
                return;
            }
        } else if (TextUtils.equals(reason, SYSTEM_HOME_KEY_LONG)) {
            //表示长按home键,显示最近使用的程序列表
            if (currentKeyCode == KeyEvent.KEYCODE_APP_SWITCH && isLongPressedRecent) {
                isLongPressedRecent = false;
                return;
            }
        } else {
            return;
        }
        refreshViewState(false);
    }
}
 
Example 3
Source File: KeyPressedTipViewController.java    From timecat with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(10);
    isLongPressedCancel = currentKeyCode == KeyEvent.KEYCODE_BACK;
    if (currentKeyCode == KeyEvent.KEYCODE_HOME) {
        isLongPressedHome = true;
    }
    if (currentKeyCode == KeyEvent.KEYCODE_APP_SWITCH) {
        isLongPressedRecent = true;
    }
    KeyPressedTipViewController.getInstance().show(null);
}
 
Example 4
Source File: KeyPressedTipViewController.java    From timecat with Apache License 2.0 5 votes vote down vote up
public void updateTriggerType() {
    keyPressIndex = SPHelper.getInt(Constants.LONG_PRESS_KEY_INDEX, 0);
    switch (keyPressIndex) {
        case 1:
            currentKeyCode = KeyEvent.KEYCODE_BACK;
            break;
        case 2:
            currentKeyCode = KeyEvent.KEYCODE_HOME;
            break;
        case 3:
            currentKeyCode = KeyEvent.KEYCODE_APP_SWITCH;
            break;
        case 4:
            currentKeyCode = KeyEvent.KEYCODE_MENU;
            break;
        case 5:
            currentKeyCode = KeyEvent.KEYCODE_VOLUME_UP;
            break;
        case 6:
            currentKeyCode = KeyEvent.KEYCODE_VOLUME_DOWN;
            break;
        case 7:
        default:
            currentKeyCode = 0;
    }
    lastKeyEvent = null;
}
 
Example 5
Source File: Lock.java    From Pi-Locker with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

	return keyCode == KeyEvent.KEYCODE_HOME
			|| keyCode == KeyEvent.KEYCODE_BACK
			|| keyCode == KeyEvent.KEYCODE_APP_SWITCH
			|| keyCode == KeyEvent.KEYCODE_SOFT_LEFT
			|| keyCode == KeyEvent.KEYCODE_SOFT_RIGHT;
	
}