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

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

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

Instrumentation.<init>介绍

暂无

代码示例

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

new Thread(new Runnable() {         
   @Override
   public void run() {
     try {
     Instrumentation inst = new Instrumentation();
     for ( int i = 0; i < 10; ++i ) {
       inst.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
       Thread.sleep(2000);
       inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
       Thread.sleep(2000);
     }
     }
     catch(InterruptedException e){
     }
   }   
 }).start();

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

Thread thread = new Thread(){
   @Override
   public void run(){
       Instrumentation m_Instrumentation = new Instrumentation();
       m_Instrumentation.sendPointerSync(MotionEvent.obtain(
           SystemClock.uptimeMillis(),
           SystemClock.uptimeMillis(),
           MotionEvent.ACTION_DOWN,posx, posy, 0));
       m_Instrumentation.sendPointerSync(MotionEvent.obtain(
           SystemClock.uptimeMillis(),
           SystemClock.uptimeMillis(),
           MotionEvent.ACTION_UP,width*4/5,height, 0));
   }
 };

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

Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendPointerSync(motionEvent);

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

new Thread(new Runnable() {         
  @Override
  public void run() {                 
    new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
  }   
}).start();

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

// Declare Variables

int softkeyboard_height = 0;
boolean calculated_keyboard_height;
Instrumentation instrumentation;

// Initialize instrumentation sometime before starting the thread
instrumentation = new Instrumentation();

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

new Thread(new Runnable() {         
  @Override
  public void run() {                 
    new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
  }   
}).start();

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

new Thread(new Runnable() {         
  @Override
  public void run() {                 
    new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
  }   
}).start();

new Thread(new Runnable() {         
  @Override
  public void run() {                 
    new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
  }   
}).start();

代码示例来源:origin: andyiac/githot

public void run() {
    try {
      Instrumentation inst = new Instrumentation();
      inst.sendKeyDownUpSync(keyCode);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}.start();

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

new Thread(new Runnable() {         
     @Override
     public void run() {
       try {
         Instrumentation inst = new Instrumentation();
         //This is for Volume Down, change to 
         //KEYCODE_VOLUME_UP for Volume Up.
         inst.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_DOWN);
       }catch(InterruptedException e){}
     }   
   }).start();

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

private void InjectKeys(final int keyEventCode) {
 new Thread(new Runnable() {
 @Override
 public void run() {
  new Instrumentation().sendKeyDownUpSync(keyEventCode);
 }
 }).start();
}

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

myThread = new Thread()
{
  public void run()
  {
    Instrumentation m_Instrumentation = new Instrumentation();
    m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_MEDIA_PREVIOUS);
  }
};

代码示例来源:origin: Shimingli/WritingPen

@Override
  public void run() {
    try {
      // 创建一个Instrumentation对象
      Instrumentation inst = new Instrumentation();
      // 调用inst对象的按键模拟方法
      inst.sendKeyDownUpSync(keyCode);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}).start();

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

new Thread(new Runnable() {         
  @Override
  public void run() {
    Instrumentation inst = new Instrumentation();
    inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
  }

}).start();

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

Instrumentation inst = new Instrumentation();
     for ( int i = 0; i < 10; ++i ) {
       inst.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
       Thread.sleep(2000);
       inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
       Thread.sleep(2000);
     }

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

IntentFilter intF = new IntentFilter("ACTIVITY.THAT.YOU.WANT.TO.LAUNCH");

Instrumentation instrumentation = new Instrumentation();

Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(intF, null, true);
Intent i = new Intent("ACTIVITY.THAT.YOU.WANT.TO.LAUNCH");
instrumentation.startActivitySync(i);

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

public class InstrumentationHelper {

  public static void sendKeyEventsFor(String word) {

    Instrumentation instrumentation = new Instrumentation();

    KeyCharacterMap mKeyCharacterMap =
        KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);

    KeyEvent[] events = mKeyCharacterMap.getEvents(word.toCharArray());

    for (KeyEvent keyEvent : events) {
      instrumentation.sendKeyDownUpSync(keyEvent.getKeyCode());
    }
  }
}

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

final Instrumentation i = new Instrumentation();
Thread t = new Thread(){
  public void run(){
   i.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
  }
};
t.start();

代码示例来源:origin: jenly1314/Base

@Override
  public void run() {
    try {
      Instrumentation inst = new Instrumentation();
      inst.sendKeyDownUpSync(keyCode);
    } catch (Exception e) {
      LogUtils.e("Exception when sendPointerSync", e);
    }
  }
});

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

Instrumentation mInstrumentation = new Instrumentation();
final Thread t = new Thread() {
   public void run(){ 
       mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_0);               
   };
t.start();

代码示例来源:origin: EggUncle/XposedNavigationBar

@Override
  protected void showPowerMenu(Context context) {
    Instrumentation mInst = new Instrumentation();
    KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POWER);
    mInst.sendKeySync(keyEvent);
  }
}

相关文章

Instrumentation类方法