Example usage for android.view KeyEvent ACTION_DOWN

List of usage examples for android.view KeyEvent ACTION_DOWN

Introduction

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

Prototype

int ACTION_DOWN

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

Click Source Link

Document

#getAction value: the key has been pressed down.

Usage

From source file:com.hxqc.mall.thirdshop.views.CustomScrollView.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy./*from  w  w  w .j  ava 2 s  .c o  m*/
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();

    if (!canScroll()) {
        if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
            View currentFocused = findFocus();
            if (currentFocused == this)
                currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
            return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!event.isAltPressed()) {
                handled = arrowScroll(View.FOCUS_UP);
            } else {
                handled = fullScroll(View.FOCUS_UP);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (!event.isAltPressed()) {
                handled = arrowScroll(View.FOCUS_DOWN);
            } else {
                handled = fullScroll(View.FOCUS_DOWN);
            }
            break;
        case KeyEvent.KEYCODE_SPACE:
            pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
            break;
        default:
            break;
        }
    }

    return handled;
}

From source file:com.amazon.android.tv.tenfoot.ui.fragments.ContentDetailsFragment.java

/**
 * Since we do not have direct access to the details overview actions row, we are adding a
 * delayed handler that waits for some time, searches for the row and then updates the
 * properties. This is not a fool-proof method,
 * > In slow devices its possible that this does not succeed in achieving the desired result.
 * > In fast devices its possible that the update is clearly visible to the user.
 * TODO: Find a better approach to update action properties
 *//*from  w w  w. java  2 s  .  co  m*/
private void updateActionsProperties() {

    Handler handler = new Handler(Looper.getMainLooper());
    handler.postDelayed(() -> {
        View view = getView();
        if (view != null) {
            HorizontalGridView horizontalGridView = (HorizontalGridView) view
                    .findViewById(R.id.details_overview_actions);

            if (horizontalGridView != null) {
                // This is required to make sure this button gets the focus whenever
                // detailsFragment is resumed.
                horizontalGridView.requestFocus();
                for (int i = 0; i < horizontalGridView.getChildCount(); i++) {
                    final Button button = (Button) horizontalGridView.getChildAt(i);
                    if (button != null) {
                        // Button objects are recreated every time MovieDetailsFragment is
                        // created or restored, so we have to bind OnKeyListener to them on
                        // resuming the Fragment.
                        button.setOnKeyListener((v, keyCode, keyEvent) -> {
                            if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
                                    && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                                button.performClick();
                            }
                            return false;
                        });
                    }
                }
            }
        }
    }, 400);
}

From source file:org.telegram.ui.ActionBar.ActionBarMenuItem.java

public ActionBarMenuItem setIsSearchField(boolean value) {
    if (parentMenu == null) {
        return this;
    }//  w  w  w .  j  ava 2 s . co  m
    if (value && searchContainer == null) {
        searchContainer = new FrameLayout(getContext());
        parentMenu.addView(searchContainer, 0);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) searchContainer.getLayoutParams();
        layoutParams.weight = 1;
        layoutParams.width = 0;
        layoutParams.height = LayoutHelper.MATCH_PARENT;
        layoutParams.leftMargin = AndroidUtilities.dp(6);
        searchContainer.setLayoutParams(layoutParams);
        searchContainer.setVisibility(GONE);

        searchField = new EditText(getContext());
        searchField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        searchField.setHintTextColor(0x88ffffff);
        searchField.setTextColor(0xffffffff);
        searchField.setSingleLine(true);
        searchField.setBackgroundResource(0);
        searchField.setPadding(0, 0, 0, 0);
        int inputType = searchField.getInputType() | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        searchField.setInputType(inputType);
        searchField.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {

            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
        searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (/*actionId == EditorInfo.IME_ACTION_SEARCH || */event != null
                        && (event.getAction() == KeyEvent.ACTION_UP
                                && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH
                                || event.getAction() == KeyEvent.ACTION_DOWN
                                        && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                    AndroidUtilities.hideKeyboard(searchField);
                    if (listener != null) {
                        listener.onSearchPressed(searchField);
                    }
                }
                return false;
            }
        });
        searchField.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (listener != null) {
                    listener.onTextChanged(searchField);
                }
                if (clearButton != null) {
                    clearButton.setAlpha(s == null || s.length() == 0 ? 0.6f : 1.0f);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        try {
            Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
            mCursorDrawableRes.setAccessible(true);
            mCursorDrawableRes.set(searchField, R.drawable.search_carret);
        } catch (Exception e) {
            //nothing to do
        }
        searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH);
        searchField.setTextIsSelectable(false);
        searchContainer.addView(searchField);
        FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) searchField.getLayoutParams();
        layoutParams2.width = LayoutHelper.MATCH_PARENT;
        layoutParams2.gravity = Gravity.CENTER_VERTICAL;
        layoutParams2.height = AndroidUtilities.dp(36);
        layoutParams2.rightMargin = AndroidUtilities.dp(48);
        searchField.setLayoutParams(layoutParams2);

        clearButton = new ImageView(getContext());
        clearButton.setImageResource(R.drawable.ic_close_white);
        clearButton.setScaleType(ImageView.ScaleType.CENTER);
        clearButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                searchField.setText("");
                searchField.requestFocus();
                AndroidUtilities.showKeyboard(searchField);
            }
        });
        searchContainer.addView(clearButton);
        layoutParams2 = (FrameLayout.LayoutParams) clearButton.getLayoutParams();
        layoutParams2.width = AndroidUtilities.dp(48);
        layoutParams2.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        layoutParams2.height = LayoutHelper.MATCH_PARENT;
        clearButton.setLayoutParams(layoutParams2);
    }
    isSearchField = value;
    return this;
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_results_resource);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        searchKeyword = extra.getString("keyWord").trim();
    }/*from   w  ww . j  a va  2  s.  c o m*/
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    imageViewClose = (ImageView) findViewById(R.id.imageViewClose);
    imageViewSearch = (ImageView) findViewById(R.id.imageViewSearch);
    editTextSearchResults = (EditText) findViewById(R.id.textViewSearch);
    switchResColl = (Switch) findViewById(R.id.switchResColl);
    dialog1 = new Dialog(this);
    editTextSearchResults.setText(searchKeyword);
    imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);
    dialog = new ProgressDialog(this);
    dialog.setTitle("gooru");
    dialog.setMessage("Please wait while loading...");
    dialog.setCancelable(false);
    dialog.show();

    if (checkInternetConnection()) {
        new getResources().execute();
    } else {
        showDialog("Please Check Internet connection");
        new getResources().execute();
    }

    // scroll views

    videoScroll = (HorizontalScrollView) findViewById(R.id.videoScroll);
    interactiveScroll = (HorizontalScrollView) findViewById(R.id.interactiveScroll);
    websiteScroll = (HorizontalScrollView) findViewById(R.id.websiteScroll);
    textbookScroll = (HorizontalScrollView) findViewById(R.id.textbookScroll);
    examScroll = (HorizontalScrollView) findViewById(R.id.examScroll);
    handoutScroll = (HorizontalScrollView) findViewById(R.id.handoutScroll);
    slideScroll = (HorizontalScrollView) findViewById(R.id.slideScroll);
    lessonScroll = (HorizontalScrollView) findViewById(R.id.lessonScroll);
    // category image load more resources
    videoRight = (ImageView) findViewById(R.id.videoRight);
    interactiveRight = (ImageView) findViewById(R.id.interactiveRight);
    websiteRight = (ImageView) findViewById(R.id.websiteRight);
    textbookRight = (ImageView) findViewById(R.id.textbookRight);
    examRight = (ImageView) findViewById(R.id.examRight);
    handoutRight = (ImageView) findViewById(R.id.handoutRight);
    slideRight = (ImageView) findViewById(R.id.slideRight);
    lessonRight = (ImageView) findViewById(R.id.lessonRight);

    videoRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                videoCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5Videos().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    interactiveRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                interactiveCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5interactive().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    imageViewSearch.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String searchKeyword = editTextSearchResults.getText().toString().trim();

            if (searchKeyword.length() > 0) {

                Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);
                searchKeyword = editTextSearchResults.getText().toString().trim();
                Log.i("Search :", searchKeyword);
                Bundle extras = new Bundle();
                extras.putString("keyWord", searchKeyword);
                intentResResults.putExtras(extras);
                startActivity(intentResResults);
                finish();

            } else {
                dialog1.setTitle("Please enter a Search keyword");
                dialog1.show();
            }
        }
    });

    websiteRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                websiteCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5website().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    textbookRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                textbookCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5textbook().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    examRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                examCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5exam().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    handoutRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                handoutCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5handout().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    slideRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                slideCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5slide().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    lessonRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                lessonCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5lesson().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    editTextSearchResults.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    String searchKeyword = editTextSearchResults.getText().toString().trim();

                    if (searchKeyword.length() > 0) {

                        Log.i("Resources", searchKeyword);
                        Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);

                        Bundle extras = new Bundle();
                        extras.putString("keyWord", searchKeyword);

                        intentResResults.putExtras(extras);
                        startActivity(intentResResults);
                        finish();
                    } else {
                        dialog1.setTitle("Please enter a Search keyword");
                        dialog1.show();
                    }
                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    imageViewClose.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            finish();
        }
    });

}

From source file:com.googlecode.eyesfree.brailleback.BrailleIME.java

private boolean sendAndroidKeyInternal(int keyCode) {
    LogUtils.log(this, Log.VERBOSE, "sendAndroidKey: %d", keyCode);
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) {
        return false;
    }//from ww w. j av  a 2  s  .  c  o m
    long eventTime = SystemClock.uptimeMillis();
    if (!ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyCode, 0 /*repeat*/))) {
        return false;
    }
    return ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, keyCode, 0 /*repeat*/));
}

From source file:com.lemon.lime.MainActivity.java

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

            if (mWebView.canGoBack()) {
                getSupportActionBar().show();
                mWebView.goBack();//from  w  ww . j av a 2 s .com
            } else {
                finish();
            }
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.holo.fileexplorer.MainActivity.java

/**
 * Since Dialogs are (almost always) attached to an activity, they are all
 * defined here to provide simple, combined access. Courtesy of OpenIntents:
 * <p>//from  www  .jav  a2 s. c  o  m
 * http://code.google.com/p/openintents/source/browse/#svn/trunk/samples/
 * TestFileManager
 * <p>
 * *Note: commented code is straight from OI, and uncommented has been
 * modified to work with HFE
 * 
 * @param id
 *            id code of the desired dialog. Defined as a set of constants
 *            within MainActivity
 * @param bundle
 *            the bundle containing any parameters to be used by the dialog
 * @return a reference to the open dialog
 */
//
@Override
protected Dialog onCreateDialog(int id, Bundle bundle) {
    switch (id) {
    case DIALOG_NEW_FOLDER:
        LayoutInflater inflater = LayoutInflater.from(this);
        View view = inflater.inflate(R.layout.dialog_new_folder, null);
        final EditText et = (EditText) view.findViewById(R.id.foldername);
        et.setText("");
        // accept "return" key
        TextView.OnEditorActionListener returnListener = new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) {
                    // match this behavior to your OK button
                    // createNewFolder(et.getText().toString());
                    dismissDialog(DIALOG_NEW_FOLDER);
                }
                return true;
            }

        };
        // et.setOnEditorActionListener(returnListener);
        // // end of code regarding "return key"
        //
        // return new AlertDialog.Builder(this)
        // .setIcon(android.R.drawable.ic_dialog_alert)
        // .setTitle(R.string.create_new_folder)
        // .setView(view)
        // .setPositiveButton(android.R.string.ok,
        // new OnClickListener() {
        //
        // public void onClick(DialogInterface dialog,
        // int which) {
        // createNewFolder(et.getText().toString());
        // }
        //
        // })
        // .setNegativeButton(android.R.string.cancel,
        // new OnClickListener() {
        //
        // public void onClick(DialogInterface dialog,
        // int which) {
        // // Cancel should not do anything.
        // }
        //
        // }).create();

        // case DIALOG_RENAME:
        // inflater = LayoutInflater.from(this);
        // view = inflater.inflate(R.layout.dialog_new_folder, null);
        // final EditText et2 = (EditText)
        // view.findViewById(R.id.foldername);
        // // accept "return" key
        // TextView.OnEditorActionListener returnListener2 = new
        // TextView.OnEditorActionListener() {
        // public boolean onEditorAction(TextView exampleView,
        // int actionId, KeyEvent event) {
        // if (actionId == EditorInfo.IME_NULL
        // && event.getAction() == KeyEvent.ACTION_DOWN) {
        // renameFileOrFolder(mContextFile, et2.getText()
        // .toString()); // match this behavior to your OK
        // // button
        // dismissDialog(DIALOG_RENAME);
        // }
        // return true;
        // }
        //
        // };
        // et2.setOnEditorActionListener(returnListener2);
        // // end of code regarding "return key"
        // return new AlertDialog.Builder(this)
        // .setTitle(R.string.menu_rename)
        // .setView(view)
        // .setPositiveButton(android.R.string.ok,
        // new OnClickListener() {
        //
        // public void onClick(DialogInterface dialog,
        // int which) {
        //
        // renameFileOrFolder(mContextFile, et2
        // .getText().toString());
        // }
        //
        // })
        // .setNegativeButton(android.R.string.cancel,
        // new OnClickListener() {
        //
        // public void onClick(DialogInterface dialog,
        // int which) {
        // // Cancel should not do anything.
        // }
        //
        // }).create();

    case DIALOG_ZIP:
        inflater = LayoutInflater.from(this);
        view = inflater.inflate(R.layout.dialog_new_folder, null);
        final EditText editText = (EditText) view.findViewById(R.id.foldername);
        // accept "return" key
        TextView.OnEditorActionListener returnListener3 = new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) {
                    mViewPager.getFragment(mPager, mPager.getCurrentItem())
                            .zipInit(editText.getText().toString());
                    // if (new File(mContextFile.getParent() +
                    // File.separator
                    // + editText.getText().toString()).exists()) {
                    // mDialogArgument = editText.getText().toString();
                    // showDialog(DIALOG_WARNING_EXISTS);
                    // } else {
                    // new CompressManager(FileManagerActivity.this)
                    // .compress(mContextFile, editText.getText()
                    // .toString());
                    // } // match this behavior to your OK button
                    dismissDialog(DIALOG_ZIP);
                }
                return true;
            }

        };
        editText.setOnEditorActionListener(returnListener3);
        // end of code regarding "return key"
        return new AlertDialog.Builder(this).setTitle(R.string.zip_dialog).setView(view)
                .setPositiveButton(android.R.string.ok, new OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        mViewPager.getFragment(mPager, mPager.getCurrentItem())
                                .zipInit(editText.getText().toString());
                        // if (new File(mContextFile.getParent()
                        // + File.separator
                        // + editText.getText().toString())
                        // .exists()) {
                        // mDialogArgument = editText.getText()
                        // .toString();
                        // showDialog(DIALOG_WARNING_EXISTS);
                        // } else {
                        // new CompressManager(
                        // FileManagerActivity.this)
                        // .compress(mContextFile,
                        // editText.getText()
                        // .toString());
                        // }
                    }
                }).setNegativeButton(android.R.string.cancel, new OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // Cancel should not do anything.
                    }
                }).create();

    }
    return super.onCreateDialog(id, bundle);

}

From source file:zjut.com.laowuguanli.activity.MainActivity.java

/**
 * Android???/*from w  ww .java  2s.c  o  m*/
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
        if ((System.currentTimeMillis() - exitTime) > 2000) {
            showHintInfo("??", "??");
            exitTime = System.currentTimeMillis();
            if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
                drawerLayout.closeDrawer(GravityCompat.START);
            }
        } else {
            System.exit(0);
            finish();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.example.tuicool.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
        if (System.currentTimeMillis() - preTime < 2000) // 
        {//www  . java  2s . c om
            finish();
        } else
            Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
        // System.exit(0);
        preTime = System.currentTimeMillis(); //  
    }
    return true;// 
}

From source file:com.sonetel.ui.dialpad.DialerFragment.java

private void keyPressed(int keyCode) {
    KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
    digits.onKeyDown(keyCode, event);
}