Best code examples for Android Instrumentation class (android.app.Instrumentation)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Instrumentation class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Instrumentation examples from Open Source projects
This code example shows how to use the following methods: sendKeySync
114:	getInstrumentation().sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, 
115:	KeyEvent.KEYCODE_VOLUME_DOWN)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTargetContext
66:	attachBaseContext(instrumentation.getTargetContext()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: callActivityOnPause, callActivityOnResume, sleep
75:	mInstr.callActivityOnPause(testActivity); 
-
78:	mInstr.callActivityOnResume(testActivity); 
-
85:	Thread.sleep(TIMEOUT); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: startActivitySync, getFlags, setFlags
64:	Intent intent = new Intent(getInstrumentation().getTargetContext(), clazz); 
65:	intent.setFlags(intent.getFlags() | FLAG_ACTIVITY_NEW_TASK); 
66:	return (T) getInstrumentation().startActivitySync(intent); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getTargetContext
48:	((AndroidTestCase) instance).setContext(instrumentation.getTargetContext()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: sendKeySync
104:	getInstrumentation().sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, 
105:	KeyEvent.KEYCODE_POWER)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: callActivityOnCreate, callApplicationOnCreate, newActivity, newApplication
64:	Activity activity = 
-
67:	Application application = 
-
71:	instrumentation.callApplicationOnCreate(application); 
-
73:	appManager.attachActivity(activity, context, instrumentation, null, 0, 
-
77:	instrumentation.callActivityOnCreate(activity, null); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendCharacterSync, waitForIdleSync, sleep
120:	inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN); 
121:	inst.waitForIdleSync(); 
122:	inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN); 
123:	inst.waitForIdleSync(); 
124:	inst.sendCharacterSync(KeyEvent.KEYCODE_BACK); 
125:	inst.waitForIdleSync(); 
-
157:	inst.waitForIdleSync(); 
-
159:	inst.waitForIdleSync(); 
-
161:	inst.waitForIdleSync(); 
-
163:	inst.waitForIdleSync(); 
-
170:	inst.waitForIdleSync(); 
-
173:	Thread.sleep(3000); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getContext, sendPointerSync, waitForIdleSync
199:	instrumentation.waitForIdleSync(); 
200:	instrumentation.sendPointerSync(motionEvent); 
-
208:	int touchSlop = ViewConfiguration.get(instrumentation.getContext()) 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods:
76:	mInst = new Instrumentation(); 
-
79:	mSolo = new Solo(mInst, activity); 
-
82:	mActivityUtils = new ActivityUtils(mInst, activity, mSleeper); 
-
84:	mScroller = new Scroller(mInst, mActivityUtils, mViewFetcher, mSleeper); 
-
86:	mClicker = new Clicker(mViewFetcher, mScroller, mRobotiumUtils, mInst, mSleeper, mWaiter); 
87:	mTextEnterer = new TextEnterer(mInst, mClicker); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: removeMonitor
318:	inst.removeMonitor(activityMonitor); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeySync, waitForIdleSync
18:	instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, 
-
20:	instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, 
-
22:	instrumentation.waitForIdleSync(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: runOnMainSync, get
107:	FutureTask<R> task = new FutureTask<R>(callable); 
-
109:	getInstrumentation().runOnMainSync(task); 
110:	return task.get(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendPointerSync, waitForIdleSync, sleep
105:	instrumentation.sendPointerSync(event); 
106:	instrumentation.waitForIdleSync(); 
-
112:	instrumentation.sendPointerSync(event); 
113:	instrumentation.waitForIdleSync(); 
-
116:	Thread.sleep((long)(ViewConfiguration.getLongPressTimeout() * 1.5f)); 
-
124:	instrumentation.sendPointerSync(event); 
125:	instrumentation.waitForIdleSync(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: sendPointerSync
98:	inst.sendPointerSync(event); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeySync, waitForIdleSync
18:	instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, 
-
20:	instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, 
-
22:	instrumentation.waitForIdleSync(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeyDownUpSync
118:	mInst.sendKeyDownUpSync(keycode); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeyDownUpSync, waitForIdleSync
227:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP); 
228:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); 
229:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); 
230:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); 
-
232:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); 
-
235:	mInstr.waitForIdleSync(); 
236:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); 
237:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_LEFT); 
238:	mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendPointerSync, waitForIdleSync
41:	instrumentation.sendPointerSync(event); 
42:	instrumentation.waitForIdleSync(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeySync, waitForIdleSync
100:	instrumentation.waitForIdleSync(); 
-
102:	instrumentation.sendKeySync( 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: waitForIdleSync, sleep
51:	instrumentation.waitForIdleSync(); 
52:	Thread.sleep(1000); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getTargetContext
53:	mContext = mInstrumentation.getTargetContext(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendCharacterSync, waitForIdleSync, sleep
120:	inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN); 
121:	inst.waitForIdleSync(); 
122:	inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN); 
123:	inst.waitForIdleSync(); 
124:	inst.sendCharacterSync(KeyEvent.KEYCODE_BACK); 
125:	inst.waitForIdleSync(); 
-
157:	inst.waitForIdleSync(); 
-
159:	inst.waitForIdleSync(); 
-
161:	inst.waitForIdleSync(); 
-
163:	inst.waitForIdleSync(); 
-
170:	inst.waitForIdleSync(); 
-
173:	Thread.sleep(3000); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: sendKeyDownUpSync, waitForIdleSync
347:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); 
348:	mInstrumentation.waitForIdleSync(); 
349:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP); 
350:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); 
351:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_LEFT); 
352:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); 
353:	mInstrumentation.waitForIdleSync(); 
-
443:	mInstrumentation.waitForIdleSync(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: sendPointerSync, waitForIdleSync
55:	inst.sendPointerSync(event); 
56:	inst.waitForIdleSync(); 
-
62:	inst.sendPointerSync(event); 
63:	inst.waitForIdleSync(); 
-
67:	inst.sendPointerSync(event); 
68:	inst.waitForIdleSync(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: sendKeyDownUpSync, waitForIdleSync, sleep
79:	mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_2); 
80:	mInstrumentation.waitForIdleSync(); 
-
85:	Thread.sleep(500); 
-
91:	Thread.sleep(1000); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: addMonitor, sendStringSync, waitForMonitorWithTimeout
57:	ActivityMonitor monitor = _ins.addMonitor( 
-
63:	_ins.sendStringSync(testString); 
-
66:	Activity activity = _ins.waitForMonitorWithTimeout(monitor, 10000); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: runOnMainSync
24:	instrumentation.runOnMainSync(task); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: addMonitor, waitForMonitor
38:	mInstrumentation.addMonitor(secondActMonitor); 
-
48:	Activity activity=mInstrumentation.waitForMonitor(secondActMonitor); 
-
51:	Solo solo2=new Solo(mInstrumentation, activity); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: sendKeyDownUpSync, sleep
53:	Instrumentation inst = new Instrumentation(); 
-
55:	inst.sendKeyDownUpSync(KeyEvent.KEYCODE_S); 
-
57:	Thread.sleep(2000); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getTargetContext
66:	attachBaseContext(instrumentation.getTargetContext()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: runOnMainSync, get
71:	FutureTask<R> task = new FutureTask<R>(callable); 
-
73:	getInstrumentation().runOnMainSync(task); 
-
75:	return task.get(); 
Full Snippet Info
5
CodeRank
Related Android Instrumentation Questions & Answers:
See Code Examples for Android Instrumentation Methods: