Example usage for android.view KeyEvent KEYCODE_HOME

List of usage examples for android.view KeyEvent KEYCODE_HOME

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_HOME.

Prototype

int KEYCODE_HOME

To view the source code for android.view KeyEvent KEYCODE_HOME.

Click Source Link

Document

Key code constant: Home key.

Usage

From source file:give_me_coins.dashboard.MainScreen.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    switch (keyCode) {
    case KeyEvent.KEYCODE_HOME:
        BackKeyExit = 0;/*  w  ww  .ja va 2s  .  c  o  m*/
        onPause();
        return true;
    case KeyEvent.KEYCODE_BACK:
        if (event.getRepeatCount() == 0) {
            if (BackKeyExit == 0) {
                Toast.makeText(this, "Press BACK twice to fully exit", Toast.LENGTH_LONG).show();
                BackKeyExit = 1;
            } else {
                if (DEBUG)
                    Log.d(TAG, "Back pressed twice - EXITING");
                BackKeyExit = 0;
                finish();
            }
        }
        if (event.getRepeatCount() == 1) {
            if (DEBUG)
                Log.d(TAG, "Back pressed twice - EXITING");
            finish();
        }
        return true;
    default:
        BackKeyExit = 0;
    }
    if (DEBUG)
        Log.d(TAG, "Pressed: " + keyCode);
    return super.onKeyDown(keyCode, event);
}

From source file:com.android.launcher2.Launcher.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (isPropertyEnabled(DUMP_STATE_PROPERTY)) {
                dumpState();/*from  w w  w  .j a  v a 2  s.  c  om*/
                return true;
            }
            break;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        }
    }

    return super.dispatchKeyEvent(event);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static boolean isComposeNowSupported() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return false;
    return !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
}

From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (doesFileExist(DUMP_STATE_PROPERTY)) {
                dumpState();/*from   w  ww  .j ava  2 s .  c om*/
                return true;
            }
            break;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        }
    }

    return super.dispatchKeyEvent(event);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            // 290661 commented this out to fix bug (Auto lock screen not popping up when back key is pressed from allapps screen)
            //TruMobiTimerClass.userInteractedStopTimer();
            if (!allAppsOpen) {
                // android.os.Process.killProcess(android.os.Process.myPid());
                mWorkspace.dispatchKeyEvent(event);

                finish();/*  w  w w  .  j a  v a2s .  com*/
            }
            mHandleView.updateIcon();
            return true;
        case KeyEvent.KEYCODE_HOME:
            return true;

        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            if (!event.isCanceled()) {
                mWorkspace.dispatchKeyEvent(event);
                if (allAppsOpen) {
                    closeDrawer();
                } else {
                    closeFolder();
                }
                if (isPreviewing()) {
                    dismissPreviews();
                }
                if (mIsEditMode) {
                    stopDesktopEdit();
                }
                if (mIsWidgetEditMode) {
                    stopWidgetEdit();
                }
            }
            return true;
        case KeyEvent.KEYCODE_HOME:
            return true;
        }
    }

    return super.dispatchKeyEvent(event);
}

From source file:com.android.launcher3.Launcher.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (Utilities.isPropertyEnabled(DUMP_STATE_PROPERTY)) {
                dumpState();/*from  w  ww .  j  a v a2 s. c o m*/
                return true;
            }
            break;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_HOME:
            return true;
        }
    }

    return super.dispatchKeyEvent(event);
}