Java Code Examples for android.view.KeyEvent

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: MainActivity.java

  33 
vote

@Override public boolean onKeyDown(final int keyCode,final KeyEvent event){
  final ActionBar actionBar=getSupportActionBar();
  if (actionBar.getSelectedNavigationIndex() == TWITTER_FRAGMENT_INDEX) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
        final WebFragment webFragment=(WebFragment)mTabsAdapter.getItem(TWITTER_FRAGMENT_INDEX);
      if (webFragment.goBack()) {
        return true;
      }
  }
}
}
return super.onKeyDown(keyCode,event);
}
 

Example 2

From project Android-Terminal-Emulator, under directory /tests/emulatorview-test/src/jackpal/androidterm/emulatorview/.

Source file: TermKeyListenerTest.java

  32 
vote

public void testKey_ALT_x_esc() throws UnsupportedEncodingException, IOException {
  tkl_AltNotEsc.setAltSendsEsc(true);
  int keycode=KeyEvent.KEYCODE_ALT_LEFT;
  KeyEvent event=new KeyEvent(1,2,KeyEvent.ACTION_DOWN,keycode,0,0);
  tkl_AltNotEsc.keyDown(keycode,event,false,true);
  keyHelperToggle(KeyEvent.KEYCODE_X,KeyEvent.META_ALT_ON,new byte[]{0x1b,0x78},true);
}
 

Example 3

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/page/.

Source file: BibleView.java

  31 
vote

/** 
 * enter text selection mode
 */
@Override public void selectAndCopyText(LongPressControl longPressControl){
  Log.d(TAG,"enter text selection mode");
  if (CommonUtils.isJellyBeanPlus()) {
    Log.d(TAG,"keycode Enter for JB+");
    KeyEvent enterEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_ENTER,0,0);
    longPressControl.ignoreNextLongPress();
    enterEvent.dispatch(this);
  }
 else {
    try {
      Log.d(TAG,"selectText for ICS");
      WebView.class.getMethod("selectText").invoke(this);
    }
 catch (    Exception e1) {
      try {
        Log.d(TAG,"emulateShiftHeld");
        Method m=WebView.class.getMethod("emulateShiftHeld",(Class[])null);
        m.invoke(this,(Object[])null);
      }
 catch (      Exception e2) {
        Log.d(TAG,"shiftPressEvent");
        KeyEvent shiftPressEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
        shiftPressEvent.dispatch(this);
      }
    }
  }
}
 

Example 4

From project andlytics, under directory /src/com/github/andlyticsproject/view/.

Source file: ChartGallery.java

  31 
vote

public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  if (useMultiImageFling) {
    return super.onFling(e1,e2,velocityX,velocityY);
  }
 else {
    boolean result=false;
    if (Math.abs(velocityX) > 900) {
      if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && velocityX <= 0) {
        KeyEvent rightKey=new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_RIGHT);
        onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT,rightKey);
        rightKey=new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_DPAD_RIGHT);
        onKeyUp(KeyEvent.KEYCODE_DPAD_RIGHT,rightKey);
        result=true;
      }
 else       if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE) {
        KeyEvent leftKey=new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_LEFT);
        onKeyDown(KeyEvent.KEYCODE_DPAD_LEFT,leftKey);
        leftKey=new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_DPAD_LEFT);
        onKeyUp(KeyEvent.KEYCODE_DPAD_LEFT,leftKey);
        result=true;
      }
    }
    return result;
  }
}
 

Example 5

From project android-thaiime, under directory /latinime/src/com/sugree/inputmethod/latin/.

Source file: LatinIME.java

  31 
vote

@Override public boolean onKeyUp(int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
    if (mKeyboardSwitcher.isInputViewShown() && mKeyboardSwitcher.isShiftedOrShiftLocked()) {
      KeyEvent newEvent=new KeyEvent(event.getDownTime(),event.getEventTime(),event.getAction(),event.getKeyCode(),event.getRepeatCount(),event.getDeviceId(),event.getScanCode(),KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON);
      final InputConnection ic=getCurrentInputConnection();
      if (ic != null)       ic.sendKeyEvent(newEvent);
      return true;
    }
  break;
}
return super.onKeyUp(keyCode,event);
}
 

Example 6

From project androidannotations, under directory /AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/.

Source file: BackpressedActivityTestSkipped.java

  31 
vote

/** 
 * Test skipped because  {@link Build.VERSION#RELEASE} is set to null inrobolectric
 */
public void backKeyHandled(){
  BackpressedActivity_ activity=new BackpressedActivity_();
  activity.onCreate(null);
  assertThat(activity.backPressed).isFalse();
  activity.onKeyDown(KeyEvent.KEYCODE_BACK,new KeyEvent(null));
  assertThat(activity.backPressed).isTrue();
}
 

Example 7

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/app/.

Source file: SherlockActivity.java

  30 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (getSherlock().dispatchKeyEvent(event)) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}
 

Example 8

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/app/.

Source file: SherlockActivity.java

  30 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (getSherlock().dispatchKeyEvent(event)) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}
 

Example 9

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/app/.

Source file: SherlockActivity.java

  29 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (getSherlock().dispatchKeyEvent(event)) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}
 

Example 10

From project aksunai, under directory /src/org/androidnerds/app/aksunai/ui/.

Source file: ChatActivity.java

  29 
vote

public boolean onKey(View v,int i,KeyEvent k){
  if (k.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
    sendUserInput();
    return false;
  }
  return false;
}
 

Example 11

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/account_create/.

Source file: AccountCreateWebViewClient.java

  29 
vote

@Override public boolean shouldOverrideKeyEvent(WebView view,KeyEvent event){
  if (event.getKeyCode() == event.KEYCODE_BACK && !view.canGoBack()) {
    IntentUtil.displayLoginActivity(AlarmApp.getInstance());
    return true;
  }
  return super.shouldOverrideKeyEvent(view,event);
}
 

Example 12

From project alljoyn_java, under directory /samples/android/chat/src/org/alljoyn/bus/sample/chat/.

Source file: DialogBuilder.java

  29 
vote

public Dialog createHostNameDialog(Activity activity,final ChatApplication application){
  Log.i(TAG,"createHostNameDialog()");
  final Dialog dialog=new Dialog(activity);
  dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
  dialog.setContentView(R.layout.hostnamedialog);
  final EditText channel=(EditText)dialog.findViewById(R.id.hostNameChannel);
  channel.setOnEditorActionListener(new TextView.OnEditorActionListener(){
    public boolean onEditorAction(    TextView view,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP) {
        String name=view.getText().toString();
        application.hostSetChannelName(name);
        application.hostInitChannel();
        dialog.cancel();
      }
      return true;
    }
  }
);
  Button okay=(Button)dialog.findViewById(R.id.hostNameOk);
  okay.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      String name=channel.getText().toString();
      application.hostSetChannelName(name);
      application.hostInitChannel();
      dialog.cancel();
    }
  }
);
  Button cancel=(Button)dialog.findViewById(R.id.hostNameCancel);
  cancel.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      dialog.cancel();
    }
  }
);
  return dialog;
}
 

Example 13

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/app/.

Source file: SherlockActivity.java

  29 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (getSherlock().dispatchKeyEvent(event)) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}
 

Example 14

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: SignupDialog.java

  29 
vote

@Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event){
  if (EditorInfo.IME_ACTION_DONE == actionId) {
    return true;
  }
  if (EditorInfo.IME_ACTION_NEXT == actionId) {
    Log.d(TAG,"Focus next!");
    name=nameEditText.getText().toString();
    email=emailEditText.getText().toString();
    password=passwordEditText.getText().toString();
    new SignupAsyncTask(getActivity(),name,email,password);
    return true;
  }
  return false;
}
 

Example 15

From project Android-automation, under directory /Tmts_Java/src/com/taobao/tmts/framework/utils/.

Source file: ActivityUtils.java

  29 
vote

/** 
 * Returns to the given  {@link Activity}.
 * @param name the name of the  {@code Activity} to return to, e.g.{@code "MyActivity"}
 */
public void goBackToActivity(String name){
  boolean found=false;
  for (  Activity activity : activityList) {
    if (activity.getClass().getSimpleName().equals(name))     found=true;
  }
  if (found) {
    while (!getCurrentActivity().getClass().getSimpleName().equals(name)) {
      try {
        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
      }
 catch (      SecurityException e) {
        Assert.assertTrue("Activity named " + name + " can not be returned to",false);
      }
    }
  }
 else {
    for (int i=0; i < activityList.size(); i++)     Log.d("Robotium","Activity priorly opened: " + activityList.get(i).getClass().getSimpleName());
    Assert.assertTrue("No Activity named " + name + " has been priorly opened",false);
  }
}
 

Example 16

From project android-bankdroid, under directory /src/com/liato/bankdroid/lockpattern/.

Source file: ChooseLockPattern.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
    if (mUiStage == Stage.HelpScreen) {
      updateStage(Stage.Introduction);
      return true;
    }
  }
  if (keyCode == KeyEvent.KEYCODE_MENU && mUiStage == Stage.Introduction) {
    updateStage(Stage.HelpScreen);
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 17

From project android-client, under directory /xwiki-android-tests-instrumentation/src/org/xwiki/android/components/tests/.

Source file: LoginActivityTests.java

  29 
vote

public void testInputUsername() throws Throwable {
  loginActivity.runOnUiThread(new Runnable(){
    public void run(){
      editTextUsername.requestFocus();
    }
  }
);
  for (int i=0; i < 15; i++) {
    this.sendKeys(KeyEvent.KEYCODE_DEL);
  }
  this.sendKeys(KeyEvent.KEYCODE_A);
  this.sendKeys(KeyEvent.KEYCODE_D);
  this.sendKeys(KeyEvent.KEYCODE_M);
  this.sendKeys(KeyEvent.KEYCODE_I);
  this.sendKeys(KeyEvent.KEYCODE_N);
  assertEquals("admin",editTextUsername.getText().toString());
}
 

Example 18

From project android-context, under directory /defunct/shared/.

Source file: SharedListActivity.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if ((keyCode == KeyEvent.KEYCODE_BACK)) {
    finish();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 19

From project android-cropimage, under directory /src/com/android/camera/.

Source file: ImageViewTouchBase.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
    event.startTracking();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 20

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: AugmentEditActivity.java

  29 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
      EditText et;
      Equipment eq;
      eq=getDAO().instantiateEquipment(mBaseID,mAugID);
      et=(EditText)findViewById(R.id.AugmentDescription);
      if (eq != null && et != null) {
        String augment;
        augment=et.getText().toString();
        if (!eq.getAugment().equals(augment)) {
          showDialog(R.string.QueryDiscardChanges);
          return true;
        }
      }
    }
  }
  return super.dispatchKeyEvent(event);
}
 

Example 21

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: Main.java

  29 
vote

@Override public boolean onKeyDown(int keycode,KeyEvent event){
  String current=mFileMag.getCurrentDir();
  if (keycode == KeyEvent.KEYCODE_SEARCH) {
    showDialog(SEARCH_B);
    return true;
  }
 else   if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && !current.equals("/")) {
    if (mHandler.isMultiSelected()) {
      mTable.killMultiSelect(true);
      Toast.makeText(Main.this,"Multi-select is now off",Toast.LENGTH_SHORT).show();
    }
 else {
      mHandler.stopThumbnailThread();
      mHandler.updateDirectory(mFileMag.getPreviousDir());
      mPathLabel.setText(mFileMag.getCurrentDir());
    }
    return true;
  }
 else   if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && current.equals("/")) {
    Toast.makeText(Main.this,"Press back again to quit.",Toast.LENGTH_SHORT).show();
    if (mHandler.isMultiSelected()) {
      mTable.killMultiSelect(true);
      Toast.makeText(Main.this,"Multi-select is now off",Toast.LENGTH_SHORT).show();
    }
    mUseBackKey=false;
    mPathLabel.setText(mFileMag.getCurrentDir());
    return false;
  }
 else   if (keycode == KeyEvent.KEYCODE_BACK && !mUseBackKey && current.equals("/")) {
    finish();
    return false;
  }
  return false;
}
 

Example 22

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: MainActivity.java

  29 
vote

@Override public boolean onKeyUp(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mBackQuit) {
      return super.onKeyUp(keyCode,event);
    }
 else {
      Toast.makeText(this,"Press back again to quit",Toast.LENGTH_SHORT).show();
      mBackQuit=true;
      return true;
    }
  }
  return super.onKeyUp(keyCode,event);
}
 

Example 23

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/activity/.

Source file: MainActivity.java

  29 
vote

@Override public boolean onKeyUp(int keyCode,KeyEvent event){
  super.onKeyUp(keyCode,event);
  if (keyCode == KeyEvent.KEYCODE_MENU) {
    mMainApplication.doAction(ACTION_SHOW_OVERFLOW_ACTIONS);
  }
  return true;
}
 

Example 24

From project Android-Flashcards, under directory /src/com/secretsockssoftware/androidflashcards/.

Source file: CardRunner.java

  29 
vote

public boolean onKeyUp(int keyCode,KeyEvent event){
  if (event.getAction() == event.ACTION_UP) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_RIGHT:
      goForwardsTo(card_pos + 1);
    return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
  goBackwardsTo(card_pos - 1);
return true;
default :
return false;
}
}
return false;
}
 

Example 25

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/.

Source file: HomeGalleryActivity.java

  29 
vote

private void showImageOptionsDialog(){
  this.mSS.inImageOptionsDialog=true;
  this.mGifFileOptionsDialog=DialogHelper.getGifFileOptionsDialog(this,this);
  this.mGifFileOptionsDialog.setOnKeyListener(new OnKeyListener(){
    @Override public boolean onKey(    DialogInterface dialog,    int keyCode,    KeyEvent event){
      if (keyCode == KeyEvent.KEYCODE_BACK)       mSS.inImageOptionsDialog=false;
      return false;
    }
  }
);
  this.mGifFileOptionsDialog.show();
}
 

Example 26

From project android-gltron, under directory /GlTron/src/com/glTron/.

Source file: glTron.java

  29 
vote

public boolean onKeyUp(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU) {
    this.startActivity(new Intent(this,Preferences.class));
  }
  return super.onKeyUp(keyCode,event);
}
 

Example 27

From project android-joedayz, under directory /Proyectos/Tipster/src/com/mycompany/tipster/.

Source file: TipsterActivity.java

  29 
vote

@Override public boolean onKey(View v,int keyCode,KeyEvent event){
switch (v.getId()) {
case R.id.txtAmount:
case R.id.txtPeople:
    btnCalculate.setEnabled(txtAmount.getText().length() > 0 && txtPeople.getText().length() > 0);
  break;
case R.id.txtTipOther:
btnCalculate.setEnabled(txtAmount.getText().length() > 0 && txtPeople.getText().length() > 0 && txtTipOther.getText().length() > 0);
break;
}
return false;
}
 

Example 28

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: MapController.java

  29 
vote

@Override public boolean onKey(View v,int keyCode,KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    return this.mapView.onKeyDown(keyCode,event);
  }
 else   if (event.getAction() == KeyEvent.ACTION_UP) {
    return this.mapView.onKeyUp(keyCode,event);
  }
  return false;
}
 

Example 29

From project android-marvin, under directory /marvin-it/src/test/android/de/akquinet/android/marvintest/activities/.

Source file: ActivityC.java

  29 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  View layout=new LinearLayout(this);
  layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  layout.setId(CONTENT_VIEW_ID);
  layout.setOnKeyListener(new OnKeyListener(){
    @Override public boolean onKey(    View v,    int keyCode,    KeyEvent event){
      keyIdentifier=keyCode;
      if (event.getAction() == KeyEvent.ACTION_DOWN)       actionIdentifierDown=true;
 else       if (event.getAction() == KeyEvent.ACTION_UP)       actionIdentifierUp=true;
      return true;
    }
  }
);
  setContentView(layout);
  layout.setFocusable(true);
  layout.setFocusableInTouchMode(true);
  layout.requestFocus();
  super.onCreate(savedInstanceState);
}
 

Example 30

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: CaptureActivity.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (isPaused) {
      Log.d(TAG,"only resuming continuous recognition, not quitting...");
      resumeContinuousDecoding();
      return true;
    }
    if (lastResult == null) {
      setResult(RESULT_CANCELED);
      finish();
      return true;
    }
 else {
      resetStatusView();
      if (handler != null) {
        handler.sendEmptyMessage(R.id.restart_preview);
      }
      return true;
    }
  }
 else   if (keyCode == KeyEvent.KEYCODE_CAMERA) {
    if (isContinuousModeActive) {
      onShutterButtonPressContinuous();
    }
 else {
      handler.hardwareShutterButtonClick();
    }
    return true;
  }
 else   if (keyCode == KeyEvent.KEYCODE_FOCUS) {
    if (event.getRepeatCount() == 0) {
      cameraManager.requestAutoFocus(500L);
    }
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 31

From project android-service-arch, under directory /ServiceFramework/src/ru/evilduck/framework/ui/.

Source file: DemoActivity.java

  29 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  text1=(EditText)findViewById(R.id.editText1);
  text2=(EditText)findViewById(R.id.editText2);
  text2.setOnEditorActionListener(new OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView textView,    int id,    KeyEvent event){
      if (id == EditorInfo.IME_ACTION_DONE) {
        doIt();
      }
      return false;
    }
  }
);
  findViewById(R.id.button_button).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      doIt();
    }
  }
);
}
 

Example 32

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/editor/activity/.

Source file: AbstractEditorActivity.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
    doSaveAction();
  break;
}
return super.onKeyDown(keyCode,event);
}
 

Example 33

From project android-tether, under directory /src/og/android/tether/.

Source file: MainActivity.java

  29 
vote

public Dialog openLaunchedDialog(final boolean noroot){
  final long value=noroot ? 1 : 0;
  EasyTracker.getTracker().trackEvent("ui_action","create_dialog","meshclient",value);
  Dialog dialog=new AlertDialog.Builder(this).setMessage(noroot ? R.string.dialog_noroot_text : R.string.dialog_launched_text).setTitle(getString(R.string.dialog_launched_title)).setIcon(R.drawable.og_app_icon).setCancelable(false).setOnKeyListener(new DialogInterface.OnKeyListener(){
    public boolean onKey(    DialogInterface dialog,    int keyCode,    KeyEvent event){
      if (keyCode == KeyEvent.KEYCODE_BACK)       MainActivity.this.finish();
      if (keyCode < KeyEvent.KEYCODE_DPAD_UP || keyCode > KeyEvent.KEYCODE_DPAD_CENTER)       return true;
 else       return false;
    }
  }
).setPositiveButton(getString(R.string.main_activity_ok),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      EasyTracker.getTracker().trackEvent("ui_action","button_press","meshclient_positive",value);
      startGooglePlayMeshclient(noroot ? "fail_noroot" : "fail");
    }
  }
).setNegativeButton(getString(R.string.main_activity_cancel),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      EasyTracker.getTracker().trackEvent("ui_action","button_press","meshclient_negative",value);
    }
  }
).create();
  dialog.show();
  return dialog;
}
 

Example 34

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: IncallActivity.java

  29 
vote

@Override public boolean onKeyUp(int keyCode,KeyEvent event){
  if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
    startActivity(new Intent().setAction(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
    return true;
  }
 else {
    return super.onKeyUp(keyCode,event);
  }
}
 

Example 35

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: VpnEditor.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
    if (validateAndSetResult())     finish();
  return true;
}
return super.onKeyDown(keyCode,event);
}
 

Example 36

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: AboutActivity.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
    mEventClientManager.sendButton("R1",ButtonCodes.REMOTE_VOLUME_PLUS,false,true,true,(short)0,(byte)0);
  return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
mEventClientManager.sendButton("R1",ButtonCodes.REMOTE_VOLUME_MINUS,false,true,true,(short)0,(byte)0);
return true;
}
return super.onKeyDown(keyCode,event);
}
 

Example 37

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: ShelvesActivity.java

  29 
vote

@Override public boolean onKeyUp(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_SEARCH) {
    return onSearchRequested();
  }
  return super.onKeyUp(keyCode,event);
}
 

Example 38

From project AndroidSensorLogger, under directory /src/com/sstp/androidsensorlogger/.

Source file: CameraActivity.java

  29 
vote

public boolean onKeyDown(int keyCode,android.view.KeyEvent event){
  Log.d(TAG,"onKeyDown");
  if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
    Log.d(TAG,"prepare to take picture");
    takePicture();
    return true;
  }
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    Log.d(TAG,"prepare save result");
    saveResult(RESULT_CANCELED);
    return super.onKeyDown(keyCode,event);
  }
  return false;
}
 

Example 39

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapActivity.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
    onBackPressed();
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 40

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: ShowMap.java

  29 
vote

@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK && mapView != null) {
    mapView.getOverlays().clear();
  }
  return super.onKeyDown(keyCode,event);
}
 

Example 41

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/app/.

Source file: SherlockActivity.java

  29 
vote

@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (getSherlock().dispatchKeyEvent(event)) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}