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.example.office.ui.Office365DemoActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        @SuppressWarnings("rawtypes")
        ItemsFragment fragment = ((ItemsFragment) getCurrentFragment());
        if (fragment != null) {
            boolean result;
            result = fragment.onKeyDown(keyCode, event);

            return result ? true : super.onKeyDown(keyCode, event);
        }//from  ww  w . jav  a 2  s  .  c o  m
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.melbournestore.activities.MainActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if ((System.currentTimeMillis() - mExitTime) > 2000) {
            Toast.makeText(this, "??", Toast.LENGTH_SHORT).show();
            mExitTime = System.currentTimeMillis();

        } else {/*from  www  .  ja va  2 s  .  c  o m*/
            SysApplication.getInstance().exit();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.lchtime.safetyexpress.ui.chat.hx.activity.HXMainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
        exit();/*from  w w  w.  j av a2s.co  m*/
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        //moveTaskToBack(false);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.android.kalite27.ScriptActivity.java

/**
 * Check if the path contains a data and a content folder
 * @param path//from   w  w  w  .  j ava  2s . co m
 * @return
 */
private boolean check_directory(String path) {
    File content_file = new File(path + "/content");
    // if the directory doesn't contain data or content folder, alert
    if (!content_file.exists()) {
        new AlertDialog.Builder(this).setTitle("Invalid Directory")
                .setMessage("The selected directory doesn't contain the content folder")
                .setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        isFileBrowserClosed = true;
                        openWebViewIfAllConditionsMeet();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        isFileBrowserClosed = true;
                        openWebViewIfAllConditionsMeet();
                    }
                }).setOnKeyListener(new DialogInterface.OnKeyListener() {
                    @Override
                    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                        if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP
                                && !event.isCanceled()) {
                            dialog.cancel();
                            isFileBrowserClosed = true;
                            openWebViewIfAllConditionsMeet();
                            return true;
                        }
                        return false;
                    }
                }).show();
        return false;
    } else {
        return true;
    }
}

From source file:org.loon.framework.android.game.LGameActivity.java

public boolean onKeyDown(int keyCode, KeyEvent e) {
    boolean ret = super.onKeyDown(keyCode, e);
    try {/*from   w  ww.  j  a v a 2  s .  co  m*/
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            LSystem.exit();
            return false;
        }
        if (gameHandler != null) {
            return gameHandler.onKeyDown(keyCode, e);
        }
    } catch (Exception ex) {

    }
    return ret;
}

From source file:bmcx.aiton.com.passenger.view.activity.SmsLoginActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        finish();/*  w w w  .  j a va 2 s  . c o  m*/
        AnimFromRightToLeft();
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.example.sleepintrain.CheckDistance.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent i = new Intent(CheckDistance.this, MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);//from  w  ww  .java2  s  .c  om
        CheckDistance.this.finish();
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.freecast.LudoCast.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

        Log.d(TAG, "Run in Back Key ");
        onDestroy();//from w w w .j a  v  a  2s. c o  m

        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.zhihuigu.sosoOffice.RegisterThirdActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);/*from ww w. j  av  a 2 s . c  o m*/
        finish();
    }
    return false;
}

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

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