Example usage for android.view KeyEvent KEYCODE_BACK

List of usage examples for android.view KeyEvent KEYCODE_BACK

Introduction

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

Prototype

int KEYCODE_BACK

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

Click Source Link

Document

Key code constant: Back key.

Usage

From source file:com.mappn.gfan.ui.HomeTabActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_BACK == keyCode) {
        if (!isFinishing()) {
            showDialog(DIALOG_EXIT);//from   www  . j  av a  2 s .c om
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.safecell.ManageProfile_Activity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {

        if (callingActivity.equals("SettingScreenActivity")) {
            Intent homeScreen = new Intent(ManageProfile_Activity.this, SettingScreenActivity.class);
            homeScreen.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homeScreen);//  w ww .  j av a2s. c  om
            finish();
        } else if (callingActivity.equals("AccountActivity")) {
            Intent homeScreen = new Intent(ManageProfile_Activity.this, AccountActivity.class);
            homeScreen.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            homeScreen.putExtra("Account_Activity_Calling", "From manage profile activity");
            startActivity(homeScreen);
            finish();
        }
    }
    return false;

}

From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        //Enable button setting
        btnInputJan.setClickable(true);//from ww w  .j a  v a  2s  .com
        //Enable button switch
        aSwitchOCR.setClickable(true);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.kiva.ohmylinux.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
            return true;
        }//from   ww w. j a  v  a  2 s . c o m

        if (drawer.isDrawerOpen(GravityCompat.END)) {
            drawer.closeDrawer(GravityCompat.END);
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.example.android.bluepayandroidsdk.MainActivity.java

@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK || KeyEvent.KEYCODE_HOME == keyCode
            || KeyEvent.KEYCODE_SEARCH == keyCode)) {

        return false;
    }/*from w  w w. j av a  2s. c o  m*/
    return super.onKeyMultiple(keyCode, repeatCount, event);
}

From source file:org.elasticdroid.SshConnectorView.java

/**
 * Handle back button. When back button pressed, we want the openPorts to be set to null
 * so that it is recomputed when the user comes back in.
 *///from  ww w.  ja  v a  2 s.  c o  m
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    //do not allow user to return to previous screen on pressing back button
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        openPorts = null;
        //cancel
    }

    return super.onKeyDown(keyCode, event);
}

From source file:ca.nehil.rter.streamingapp.StreamingActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (recording) {
            stopRecording();// w  w  w.jav a  2 s.  c  o m
        }
        finish();
        return true;

    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        createBeacon();
    } else if (keyCode == KeyEvent.KEYCODE_CAMERA) {
        // Camera button clicked.
    }

    return super.onKeyDown(keyCode, event);
}

From source file:android.widget.TiVideoView4.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mIsPrepared && keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP
            && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_MENU
            && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL && mMediaPlayer != null
            && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();// w  w  w  .ja va 2s  .c om
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP && mMediaPlayer.isPlaying()) {
            pause();
            mMediaController.show();
        } else {
            toggleMediaControlsVisiblity();
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.example.android.bluepayandroidsdk.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK || KeyEvent.KEYCODE_HOME == keyCode
            || KeyEvent.KEYCODE_SEARCH == keyCode)) {
        return false;
    }/*  w ww.  j a v a 2 s .  c  o  m*/
    return super.onKeyUp(keyCode, event);
}

From source file:com.aegamesi.steamtrade.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        toggleDrawer();/*from  w w w . ja  va 2 s . co m*/
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Fragment activeFragment = getSupportFragmentManager().findFragmentById(R.id.content_frame);
        if (activeFragment instanceof FragmentWeb) {
            // go *back* if possible
            if (((FragmentWeb) activeFragment).onBackPressed())
                return true;
        }
    }

    return super.onKeyUp(keyCode, event);
}