KeyEvent getEventTime - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for KeyEvent getEventTime method.

This code example shows how to use the following methods:getAction, getEventTime, getKeyCode, getMetaState, getUnicodeChar
    } 
 
    boolean translateAndSendNativeEvents(KeyEvent event) {
        if (mNativeImeAdapterAndroid == 0) return false;
 
        int action = event.getAction();
        if (action != KeyEvent.ACTION_DOWN &&
            action != KeyEvent.ACTION_UP) {
            // action == KeyEvent.ACTION_MULTIPLE 
            // TODO(bulach): confirm the actual behavior. Apparently: 
            // If event.getKeyCode() == KEYCODE_UNKNOWN, we can send a 
            // composition key down (229) followed by a commit text with the 
            // string from event.getUnicodeChars(). 
            // Otherwise, we'd need to send an event with a 
            // WebInputEvent::IsAutoRepeat modifier. We also need to verify when 
            // we receive ACTION_MULTIPLE: we may receive it after an ACTION_DOWN, 
            // and if that's the case, we'll need to review when to send the Char 
            // event. 
            return false; 
        } 

7
CodeRank
This code example shows how to use the following methods:getAction, getDownTime, getEventTime, getKeyCode
			KeyEvent evt = (KeyEvent)b.get("android.intent.extra.KEY_EVENT");
			 
			 
			if(player.isActive()) {
				if(evt != null) {
					if(evt.getAction() == KeyEvent.ACTION_DOWN) {
						 
						//downTime = evt.getDownTime(); 
						Log.d(TAG, "TIME %d %d", evt.getDownTime(), evt.getEventTime());
						 
						//if(!actionHandled) { 
						//	if(evt.getRepeatCount() > 2) { 
						//		playNextSong(); 
						//		actionHandled = true; 
						//	} 
						//} 
					} else if(evt.getAction() == KeyEvent.ACTION_UP) {
						 
						int keycode = evt.getKeyCode();
				 

7
CodeRank
This code example shows how to use the following methods:getAction, getEventTime, getKeyCode
			} 
			if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) {
				KeyEvent event = (KeyEvent) intent
						.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
 
				if (event.getAction() == KeyEvent.ACTION_DOWN) {
					return; 
				} 
 
				keyCode = event.getKeyCode();
 
				if (KeyEvent.KEYCODE_HEADSETHOOK == keyCode) {
					sGestureHelper.onHeadsetButtonPressed(event.getEventTime(), context);
				} 
			} 
		 
			if (keyCode != -1) {
				boolean autoStart = keyCode != KeyEvent.KEYCODE_MEDIA_PAUSE && keyCode != KeyEvent.KEYCODE_MEDIA_STOP;
				sendKeyCode(context, keyCode, autoStart);
			} 
6
CodeRank
This code example shows how to use the following methods:getAction, getEventTime
        // action 
        // the the up action will cause the device to wake back up. 
 
        // Log.i(TAG, "keyCode: " + keyCode + " action: " + event.getAction()); 
        if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER
                || event.getAction() != KeyEvent.ACTION_UP) {
            // Log.i(TAG, "getting out of dodge..."); 
            return false; 
        } 
 
        // Log.i(TAG, "Clicked mKeyguard! dimissing dialog"); 
        this.dismiss();
        // Log.i(TAG, "onKey: turning off the screen..."); 
        // XXX: arve says this is a hack for now 
        mPowerManager.goToSleep(event.getEventTime() + 1);
        return true; 
    } 
 
    public void show() { 
        super.show(); 
6
CodeRank
This code example shows how to use the following methods:getEventTime
    public long getDownTime() { 
        return mKeyEvent != null ? mKeyEvent.getDownTime() : mDownTime;
    } 
 
    public long getEventTime() { 
        return mKeyEvent != null ? mKeyEvent.getEventTime() : mEventTime;
    } 
 
    public void setDownTime(long downTime) {
        if (mKeyEvent != null) {
            throw new IllegalStateException("Cannot modify down time of this key event.");
        } 
        mDownTime = downTime;
    } 
 
    public void setEventTime(long eventTime) {
        if (mKeyEvent != null) {
            throw new IllegalStateException("Cannot modify event time of this key event.");
        } 
        mEventTime = eventTime;
6
CodeRank
This code example shows how to use the following methods:getEventTime
	 */ 
	public boolean onKeyUp(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
			Log.d(TAG, "D-Pad");
			// prevent too may scroll events causing multi-page changes 
			if (event.getEventTime()-lastHandledDpadEventTime>1000) {
				if (keyCode==KeyEvent.KEYCODE_DPAD_RIGHT) {
					CurrentPageManager.getInstance().getCurrentPage().next(); 
				} else { 
					CurrentPageManager.getInstance().getCurrentPage().previous(); 
				} 
				lastHandledDpadEventTime = event.getEventTime();
				return true; 
			} 
		} 
		return false; 
	} 
 
 
} 
5
CodeRank

Related KeyEvent getEventTime Questions & Answers:

getEventTime Method Overview
Retrieve the time this event occurred, in the uptimeMillis() time base.
See Code Examples for other Android KeyEvent Methods: