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.findcab.activity.LocationOverlay.java

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

        //         exitDialog(context);
        //??home?
        Intent intents = new Intent(Intent.ACTION_MAIN);
        intents.addCategory(Intent.CATEGORY_HOME);
        intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intents);/*from  ww  w.  j a va  2 s  . c o m*/
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:

            String d = usernum + "-" + getStripNumber(prefs.getString(stored_chatuserNumber, "")) + "-nt";
            if (ChatSocket.socket != null) {
                ChatSocket.ps.print(d);/*from  w ww.  java  2s. c o  m*/
            }

            Log.d("ps d onKeyDown", d + " @");

            MessageFragment.keyboard_flag = false;
            btn_emoticon_show.setImageResource(R.drawable.smily_icon);
            if (Fl_Emoticon_Holder.getVisibility() == 0) {
                Fl_Emoticon_Holder.setVisibility(FrameLayout.GONE);
            } else {
                finish();
            }
            return true;
        }

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

From source file:com.dish.browser.activity.BrowserActivity.java

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        showCloseDialog(mDrawerListLeft.getCheckedItemPosition());
    }//from  w  w  w.j  ava  2  s . c o m
    return true;
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        // Log.i(AnkiDroidApp.TAG, "Reviewer - onBackPressed()");
        closeReviewer(RESULT_DEFAULT, false);
        return true;
    }//from   w  w w  .ja  v  a2s.c  o m
    /** Enhancement 722: Hardware buttons for scrolling, I.Z. */
    if (!mCurrentSimpleInterface) {
        if (keyCode == 92) {
            mCard.pageUp(false);
            if (mDoubleScrolling) {
                mCard.pageUp(false);
            }
            return true;
        }
        if (keyCode == 93) {
            mCard.pageDown(false);
            if (mDoubleScrolling) {
                mCard.pageDown(false);
            }
            return true;
        }
        if (mScrollingButtons && keyCode == 94) {
            mCard.pageUp(false);
            if (mDoubleScrolling) {
                mCard.pageUp(false);
            }
            return true;
        }
        if (mScrollingButtons && keyCode == 95) {
            mCard.pageDown(false);
            if (mDoubleScrolling) {
                mCard.pageDown(false);
            }
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:cn.kangeqiu.kq.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.v("TAG", "on back1");
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (System.currentTimeMillis() - keyDownTime < 4000) {

            Log.v("tag", "1=" + keyDownTime);
            moveTaskToBack(false);//  w  ww.  j a  va2s  . com
            mam.finishAllActivity();
            finish();
            return true;
        }

        keyDownTime = System.currentTimeMillis();
        Log.v("tag", "2=" + keyDownTime);
        Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
    }

    return true;
}

From source file:com.quwu.xinwo.release.Release_Activity.java

/**
 * // w  w  w  . java 2  s  . c o  m
 * ?
 * 
 * */
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {

    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        int visibility = keyboardView.getVisibility();
        if (visibility == View.VISIBLE || visibility == View.INVISIBLE) {
            keyboardView.setVisibility(View.GONE);
        } else {
            this.finish();
        }
        return false;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (!mFlag) {
            Toast.makeText(getApplicationContext(), "''     .",
                    Toast.LENGTH_SHORT).show();
            mFlag = true;//from   ww w  .j  a  v a 2 s.c om
            mFinishHandler.sendEmptyMessageDelayed(0, 2000);
            return false;
        } else {
            finish();
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.esri.squadleader.view.SquadLeaderActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean ret;/*from  w  w  w.  j  a  v a2 s .  c  o  m*/
    if (KeyEvent.KEYCODE_BACK == keyCode && 0 == event.getRepeatCount()) {
        // Override the Back button when the feature popup bottom sheet is showing.
        ret = goBackFromPopupSheet();
        if (!ret) {
            ret = super.onKeyDown(keyCode, event);
        }
    } else {
        ret = super.onKeyDown(keyCode, event);
    }
    return ret;
}

From source file:com.msopentech.applicationgateway.EnterpriseBrowserActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    try {/*  w  ww. j a  v  a2 s .co  m*/
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            if (mActiveWebView.canGoBack()) {
                mActiveWebView.goBack();
                return true;
            }
        }
    } catch (Exception e) {
        Utility.showAlertDialog(
                EnterpriseBrowserActivity.class.getSimpleName() + ".onKeyDown(): Failed. " + e.toString(),
                EnterpriseBrowserActivity.this);
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.irccloud.android.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) { //Back key pressed
        if (drawerLayout != null
                && (drawerLayout.isDrawerOpen(Gravity.LEFT) || drawerLayout.isDrawerOpen(Gravity.RIGHT))) {
            drawerLayout.closeDrawers();
            return true;
        }//from  w w  w .  ja v  a 2 s. co  m
        while (backStack != null && backStack.size() > 0) {
            Integer bid = backStack.get(0);
            backStack.remove(0);
            if (buffer == null || bid != buffer.bid) {
                BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBuffer(bid);
                if (b != null) {
                    onBufferSelected(bid);
                    if (backStack.size() > 0)
                        backStack.remove(0);
                    return true;
                }
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}