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.darshancomputing.BatteryIndicator.BatteryInfoActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && viewPager.getCurrentItem() != 0) {
        viewPager.setCurrentItem(0);//from w ww .  j a  v a2s .co m
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.darshancomputing.BatteryIndicatorPro.BatteryInfoActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && viewPager.getCurrentItem() != 1) {
        viewPager.setCurrentItem(1);/* w w  w.j  ava 2s .  com*/
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.ichi2.anki.CramDeckActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        Log.i(AnkiDroidApp.TAG, "StudyOptions - onBackPressed()");
        //         if (mCurrentContentView == CONTENT_CONGRATS) {
        //            finishCongrats();
        //         } else {
        //            closeStudyOptions();
        //         }
        closeCramDeckAdder();//  w  w  w.j av  a  2s  . c o  m
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:android.support.v17.leanback.app.BrowseFragmentTest.java

public void testTwoBackKeysWithoutBackStack() throws Throwable {
    mInstrumentation = getInstrumentation();
    Intent intent = new Intent(mInstrumentation.getContext(), BrowseFragmentTestActivity.class);
    intent.putExtra(BrowseFragmentTestActivity.EXTRA_LOAD_DATA_DELAY, (long) 1000);
    intent.putExtra(BrowseFragmentTestActivity.EXTRA_ADD_TO_BACKSTACK, false);
    initActivity(intent);//  ww w.  j  ava  2 s.  com

    sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
    Thread.sleep(TRANSITION_LENGTH);

    sendKeys(KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_BACK);
}

From source file:com.HskPackage.HskNamespace.HSK1ProjectActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        finish();// ww w  .j  a  v a  2  s .  c  om
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.example.ies_sms_demo.EquipementSlideActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        return false;
    }// www.j  av a 2  s  .c o m
    return super.onKeyDown(keyCode, event);
}

From source file:org.cocos2dx.lib.Cocos2dxEditText.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    super.onKeyDown(keyCode, event);

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        mView.requestFocus();//from   w w  w  .j  av a  2s  .  c om
    }

    return true;
}

From source file:com.example.fastgive.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (inScanMode)
            finish();/*  w  w w .j  ava 2  s .  c o m*/
        else
            onResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.darly.im.ui.CCPFragment.java

/**
 * ?//from ww  w  .  j  a  v  a 2 s  .  com
 * @param keyCode
 * @param event
 * @return
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mBaseActivity.onKeyDown(keyCode, event)) {
        return true;
    }
    if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_DOWN) {
        finish();
        return true;
    }
    return false;
}

From source file:android.support.v17.leanback.app.BrowseSupportFragmentTest.java

public void testTwoBackKeysWithoutBackStack() throws Throwable {
    mInstrumentation = getInstrumentation();
    Intent intent = new Intent(mInstrumentation.getContext(), BrowseSupportFragmentTestActivity.class);
    intent.putExtra(BrowseSupportFragmentTestActivity.EXTRA_LOAD_DATA_DELAY, (long) 1000);
    intent.putExtra(BrowseSupportFragmentTestActivity.EXTRA_ADD_TO_BACKSTACK, false);
    initActivity(intent);/* w w w . j ava2 s  . co m*/

    sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
    Thread.sleep(TRANSITION_LENGTH);

    sendKeys(KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_BACK);
}