當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyCharacterMap.VIRTUAL_KEYBOARD屬性代碼示例

本文整理匯總了Java中android.view.KeyCharacterMap.VIRTUAL_KEYBOARD屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyCharacterMap.VIRTUAL_KEYBOARD屬性的具體用法?Java KeyCharacterMap.VIRTUAL_KEYBOARD怎麽用?Java KeyCharacterMap.VIRTUAL_KEYBOARD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyCharacterMap的用法示例。


在下文中一共展示了KeyCharacterMap.VIRTUAL_KEYBOARD屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendKeyAndWaitForEvent

/**
 * Send keys and blocks until the first specified accessibility event.
 *
 * Most key presses will cause some UI change to occur. If the device is busy, this will
 * block until the device begins to process the key press at which point the call returns
 * and normal wait for idle processing may begin. If no events are detected for the
 * timeout period specified, the call will return anyway with false.
 *
 * @param keyCode
 * @param metaState
 * @param eventType
 * @param timeout
 * @return true if events is received, otherwise false.
 */
public boolean sendKeyAndWaitForEvent(final int keyCode, final int metaState, final int eventType, long timeout) {
	Runnable command = new Runnable() {
		@Override
		public void run() {
			final long eventTime = SystemClock.uptimeMillis();
			KeyEvent downEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD);
			if (injectEventSync(downEvent)) {
				KeyEvent upEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD);
				injectEventSync(upEvent);
			}
		}
	};

	return runAndWaitForEvents(command, new WaitForAnyEventPredicate(eventType), timeout) != null;
}
 
開發者ID:MagicHry,項目名稱:EnhancedPUMA,代碼行數:29,代碼來源:MyInteractionController.java

示例2: injectKey

protected void injectKey(int keycode) {
	InputManager inputManager = (InputManager) XposedHelpers
			.callStaticMethod(InputManager.class, "getInstance");
	long now = SystemClock.uptimeMillis();
	final KeyEvent downEvent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN,
			keycode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD,
			0, KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_KEYBOARD);
	final KeyEvent upEvent = KeyEvent.changeAction(downEvent,
			KeyEvent.ACTION_UP);

	Integer INJECT_INPUT_EVENT_MODE_ASYNC = XposedHelpers
			.getStaticIntField(InputManager.class,
					"INJECT_INPUT_EVENT_MODE_ASYNC");

	XposedHelpers.callMethod(inputManager, "injectInputEvent", downEvent,
			INJECT_INPUT_EVENT_MODE_ASYNC);
	XposedHelpers.callMethod(inputManager, "injectInputEvent", upEvent,
			INJECT_INPUT_EVENT_MODE_ASYNC);

}
 
開發者ID:adipascu,項目名稱:XposedMenuBeGone,代碼行數:20,代碼來源:Main.java

示例3: sendEvent

void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) {
    try {
        final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0;
        if (applyDefaultFlags) {
            flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
        }
        final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount,
                0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags,
                InputDevice.SOURCE_KEYBOARD);
        final Object inputManager = XposedHelpers.callStaticMethod(InputManager.class, "getInstance");
        XposedHelpers.callMethod(inputManager, "injectInputEvent", ev, 0);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:15,代碼來源:KeyButtonView.java

示例4: sendKey

public boolean sendKey(int keyCode, int metaState) {
	if (DEBUG) {
		Log.d(LOG_TAG, "sendKey (" + keyCode + ", " + metaState + ")");
	}

	final long eventTime = SystemClock.uptimeMillis();
	KeyEvent downEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD);
	if (injectEventSync(downEvent)) {
		KeyEvent upEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD);
		if (injectEventSync(upEvent)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:MagicHry,項目名稱:EnhancedPUMA,代碼行數:15,代碼來源:MyInteractionController.java

示例5: onCreateInputConnection

@Override
public InputConnection onCreateInputConnection (EditorInfo outAttrs) {

	// add this line, the IME can show the selectable words when use chinese input method editor.
	if (outAttrs != null) {
		outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
	}

	BaseInputConnection connection = new BaseInputConnection(this, false) {
		@Override
		public boolean deleteSurroundingText (int beforeLength, int afterLength) {
			int sdkVersion = android.os.Build.VERSION.SDK_INT;
			if (sdkVersion >= 16) {
				/*
				 * In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
				 * we'll just simulate what it used to do.
				 */
				if (beforeLength == 1 && afterLength == 0) {
					sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
					return true;
				}
			}
			return super.deleteSurroundingText(beforeLength, afterLength);
		}

		@TargetApi(16)
		private void sendDownUpKeyEventForBackwardCompatibility (final int code) {
			final long eventTime = SystemClock.uptimeMillis();
			super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0,
				KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
			super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0,
				KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
		}
	};
	return connection;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:36,代碼來源:GLSurfaceView20.java

示例6: onCreateInputConnection

@Override
public InputConnection onCreateInputConnection (EditorInfo outAttrs) {

	// add this line, the IME can show the selectable words when use chinese input method editor.
	if (outAttrs != null) {
		outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
	}
	
	BaseInputConnection connection = new BaseInputConnection(this, false) {
		@Override
		public boolean deleteSurroundingText (int beforeLength, int afterLength) {
			int sdkVersion = android.os.Build.VERSION.SDK_INT;
			if (sdkVersion >= 16) {
				/*
				 * In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
				 * we'll just simulate what it used to do.
				 */
				if (beforeLength == 1 && afterLength == 0) {
					sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
					return true;
				}
			}
			return super.deleteSurroundingText(beforeLength, afterLength);
		}

		@TargetApi(16)
		private void sendDownUpKeyEventForBackwardCompatibility (final int code) {
			final long eventTime = SystemClock.uptimeMillis();
			super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0,
				KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
			super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0,
				KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
		}
	};
	return connection;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:36,代碼來源:GLSurfaceView20API18.java


注:本文中的android.view.KeyCharacterMap.VIRTUAL_KEYBOARD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。