android.app.Instrumentation.sendCharacterSync()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中android.app.Instrumentation.sendCharacterSync()方法的一些代码示例,展示了Instrumentation.sendCharacterSync()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.sendCharacterSync()方法的具体详情如下:
包路径:android.app.Instrumentation
类名称:Instrumentation
方法名:sendCharacterSync

Instrumentation.sendCharacterSync介绍

暂无

代码示例

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void sendCharacterSync(int keyCode) {
  base.sendCharacterSync(keyCode);
}

代码示例来源:origin: RobotiumTech/robotium

/**
 * Tells Robotium to send a key code: Right, Left, Up, Down, Enter or other.
 * 
 * @param keycode the key code to be sent. Use {@link KeyEvent#KEYCODE_ENTER}, {@link KeyEvent#KEYCODE_MENU}, {@link KeyEvent#KEYCODE_DEL}, {@link KeyEvent#KEYCODE_DPAD_RIGHT} and so on
 */
public void sendKeyCode(int keycode)
{
  sleeper.sleep();
  try{
    inst.sendCharacterSync(keycode);
  }catch(SecurityException e){
    Assert.fail("Can not complete action! ("+(e != null ? e.getClass().getName()+": "+e.getMessage() : "null")+")");
  }
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
public void sendCharacterSync(int keyCode) {
  base.sendCharacterSync(keyCode);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public void sendCharacterSync(int keyCode) {
  base.sendCharacterSync(keyCode);
}

代码示例来源:origin: stackoverflow.com

public void testSearch() { 
  Instrumentation instrumentation = getInstrumentation(); 
  instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_SEARCH); 
  instrumentation.sendCharacterSync(KeyEvent.KEYCODE_F); 
  instrumentation.sendCharacterSync(KeyEvent.KEYCODE_O); 
  instrumentation.sendCharacterSync(KeyEvent.KEYCODE_O);
  //Assert here for whatever you want. 
}

代码示例来源:origin: stackoverflow.com

final Instrumentation instrumentation = new Instrumentation();

new Thread(new Runnable()
{
  @Override
  public void run()
  {
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_H);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_TAB);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_T);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_H);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_R);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E);
  }
}).start();

代码示例来源:origin: luili16/UIMocker

@Override
@CallSuper
public void sendCharacterSync(int keyCode) {
  if (DEBUG) {
    Logger.d(TAG,"sendCharacterSync");
  }
  mInstrumentation.sendCharacterSync(keyCode);
}

代码示例来源:origin: com.jayway.android.robotium/robotium-solo

/**
 * Tells Robotium to send a key code: Right, Left, Up, Down, Enter or other.
 * 
 * @param keycode the key code to be sent. Use {@link KeyEvent#KEYCODE_ENTER}, {@link KeyEvent#KEYCODE_MENU}, {@link KeyEvent#KEYCODE_DEL}, {@link KeyEvent#KEYCODE_DPAD_RIGHT} and so on
 */
public void sendKeyCode(int keycode)
{
  sleeper.sleep();
  try{
    inst.sendCharacterSync(keycode);
  }catch(SecurityException e){
    Assert.fail("Can not complete action! ("+(e != null ? e.getClass().getName()+": "+e.getMessage() : "null")+")");
  }
}

代码示例来源:origin: com.jayway.android.robotium/robotium-core

/**
 * Tells Robotium to send a key code: Right, Left, Up, Down, Enter or other.
 * @param keycode the key code to be sent. Use {@link KeyEvent#KEYCODE_ENTER}, {@link KeyEvent#KEYCODE_MENU}, {@link KeyEvent#KEYCODE_DEL}, {@link KeyEvent#KEYCODE_DPAD_RIGHT} and so on...
 * 
 */

public void sendKeyCode(int keycode)
{
  sleeper.sleep();
  inst.waitForIdleSync();
  try{
    inst.sendCharacterSync(keycode);
  }catch(SecurityException e){
    Assert.assertTrue("Can not complete action!", false);
  }
}

代码示例来源:origin: stackoverflow.com

final Instrumentation instrumentation = getInstrumentation();
       final long downTime = SystemClock.uptimeMillis();
       final long eventTime = SystemClock.uptimeMillis();
       final KeyEvent altDown = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_DOWN,
           KeyEvent.KEYCODE_GRAVE, 1, KeyEvent.META_ALT_LEFT_ON);
       final KeyEvent altUp = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP,
           KeyEvent.KEYCODE_GRAVE, 1, KeyEvent.META_ALT_LEFT_ON);
       instrumentation.sendKeySync(altDown);
       instrumentation.sendCharacterSync(KeyEvent.KEYCODE_A);
       instrumentation.sendKeySync(altUp);
       instrumentation.sendKeySync(altDown);
       instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E);
       instrumentation.sendKeySync(altUp);
       instrumentation.sendKeySync(altDown);
       instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I);
       instrumentation.sendKeySync(altUp);
       instrumentation.sendKeySync(altDown);
       instrumentation.sendCharacterSync(KeyEvent.KEYCODE_O);
       instrumentation.sendKeySync(altUp);
       instrumentation.sendKeySync(altDown);
       instrumentation.sendCharacterSync(KeyEvent.KEYCODE_U);
       instrumentation.sendKeySync(altUp);

相关文章

Instrumentation类方法