1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119<!DOCTYPE html>
120<html devsite>
121<head>
122
123
124    <meta name="top_category" value="develop" />
125
126    <meta name="subcategory" value="reference" />
127
128
129      <meta name="book_path" value="/reference/android/support/test/_book.yaml" />
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145<title>UiDevice</title>
146
147
148</head>
149
150<body class="gc-documentation develop reference api apilevel-">
151<div id="doc-api-level" class="" style="display:none"></div>
152
153
154
155
156<div id="naMessage"></div>
157
158<div id="api-info-block">
159<div class="api-level">
160
161
162
163
164</div>
165
166
167
168
169
170
171
172
173
174
175
176<div class="sum-details-links">
177
178Summary:
179
180
181
182
183
184
185
186
187
188
189
190  <a href="#pubmethods">Methods</a>
191
192
193
194
195  &#124; <a href="#inhmethods">Inherited Methods</a>
196
197&#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
198
199</div><!-- end sum-details-links -->
200</div><!-- end api-info-block -->
201
202<div class="api apilevel-" id="jd-content">
203
204<!-- ======== START OF CLASS DATA ======== -->
205
206<h1 class="api-title">UiDevice</h1>
207<p>
208<code class="api-signature">
209  public
210
211
212
213  class
214  UiDevice
215</code>
216<br>
217
218
219<code class="api-signature">
220
221    extends Object
222
223
224
225</code>
226
227<code class="api-signature">
228
229
230
231</code>
232
233</p><table class="jd-inheritance-table">
234
235
236  <tr>
237
238    <td colspan="2" class="jd-inheritance-class-cell">java.lang.Object
239    </td>
240  </tr>
241
242
243  <tr>
244
245      <td class="jd-inheritance-space">&nbsp;&nbsp;&nbsp;&#x21b3;</td>
246
247    <td colspan="1" class="jd-inheritance-class-cell">android.support.test.uiautomator.UiDevice
248    </td>
249  </tr>
250
251
252</table>
253
254
255
256
257<br><hr>
258
259
260  <p>UiDevice provides access to state information about the device.
261 You can also use this class to simulate user actions on the device,
262 such as pressing the d-pad or pressing the Home and Menu buttons.</p>
263
264
265
266
267
268
269
270<h2 class="api-section">Summary</h2>
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298<!-- ========== METHOD SUMMARY =========== -->
299<table id="pubmethods" class="responsive methods">
300<tr><th colspan="2"><h3>Public methods</h3></th></tr>
301
302
303
304
305  <tr class="api apilevel-" >
306
307
308    <td><code>
309
310
311
312
313
314        void</code>
315    </td>
316
317    <td width="100%">
318      <code>
319      <a href="/reference/android/support/test/uiautomator/UiDevice.html#clearLastTraversedText()">clearLastTraversedText</a>()
320      </code>
321
322        <p>Clears the text from the last UI traversal event.
323
324
325</p>
326
327    </td>
328  </tr>
329
330
331
332  <tr class="api apilevel-" >
333
334
335    <td><code>
336
337
338
339
340
341        boolean</code>
342    </td>
343
344    <td width="100%">
345      <code>
346      <a href="/reference/android/support/test/uiautomator/UiDevice.html#click(int, int)">click</a>(int x, int y)
347      </code>
348
349        <p>Perform a click at arbitrary coordinates specified by the user
350
351
352</p>
353
354    </td>
355  </tr>
356
357
358
359  <tr class="api apilevel-" >
360
361
362    <td><code>
363
364
365
366
367
368        boolean</code>
369    </td>
370
371    <td width="100%">
372      <code>
373      <a href="/reference/android/support/test/uiautomator/UiDevice.html#drag(int, int, int, int, int)">drag</a>(int startX, int startY, int endX, int endY, int steps)
374      </code>
375
376        <p>Performs a swipe from one coordinate to another coordinate.
377
378
379</p>
380
381    </td>
382  </tr>
383
384
385
386  <tr class="api apilevel-" >
387
388
389    <td><code>
390
391
392
393
394
395        void</code>
396    </td>
397
398    <td width="100%">
399      <code>
400      <a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.File)">dumpWindowHierarchy</a>(File dest)
401      </code>
402
403        <p>Dump the current window hierarchy to a <code><a href="/reference/java/io/File.html">File</a></code>.
404
405
406</p>
407
408    </td>
409  </tr>
410
411
412
413  <tr class="api apilevel-" >
414
415
416    <td><code>
417
418
419
420
421
422        void</code>
423    </td>
424
425    <td width="100%">
426      <code>
427      <a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.OutputStream)">dumpWindowHierarchy</a>(OutputStream out)
428      </code>
429
430        <p>Dump the current window hierarchy to an <code><a href="/reference/java/io/OutputStream.html">OutputStream</a></code>.
431
432
433</p>
434
435    </td>
436  </tr>
437
438
439
440  <tr class="api apilevel-" >
441
442
443    <td><code>
444
445
446
447
448
449        void</code>
450    </td>
451
452    <td width="100%">
453      <code>
454      <a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.lang.String)">dumpWindowHierarchy</a>(String fileName)
455      </code>
456
457        <p><em>
458      This method is deprecated.
459    Use <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.File)">dumpWindowHierarchy(File)</a></code> or
460     <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.OutputStream)">dumpWindowHierarchy(OutputStream)</a></code> instead.
461</em>
462
463
464</p>
465
466    </td>
467  </tr>
468
469
470
471  <tr class="api apilevel-" >
472
473
474    <td><code>
475
476
477
478
479
480        <a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a></code>
481    </td>
482
483    <td width="100%">
484      <code>
485      <a href="/reference/android/support/test/uiautomator/UiDevice.html#findObject(android.support.test.uiautomator.BySelector)">findObject</a>(<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)
486      </code>
487
488        <p>Returns the first object to match the <code>selector</code> criteria.
489
490
491</p>
492
493    </td>
494  </tr>
495
496
497
498  <tr class="api apilevel-" >
499
500
501    <td><code>
502
503
504
505
506
507        <a href="/reference/android/support/test/uiautomator/UiObject.html">UiObject</a></code>
508    </td>
509
510    <td width="100%">
511      <code>
512      <a href="/reference/android/support/test/uiautomator/UiDevice.html#findObject(android.support.test.uiautomator.UiSelector)">findObject</a>(<a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a> selector)
513      </code>
514
515        <p>Returns a UiObject which represents a view that matches the specified selector criteria.
516
517
518</p>
519
520    </td>
521  </tr>
522
523
524
525  <tr class="api apilevel-" >
526
527
528    <td><code>
529
530
531
532
533
534        List&lt;<a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a>&gt;</code>
535    </td>
536
537    <td width="100%">
538      <code>
539      <a href="/reference/android/support/test/uiautomator/UiDevice.html#findObjects(android.support.test.uiautomator.BySelector)">findObjects</a>(<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)
540      </code>
541
542        <p>Returns all objects that match the <code>selector</code> criteria.
543
544
545</p>
546
547    </td>
548  </tr>
549
550
551
552  <tr class="api apilevel-" >
553
554
555    <td><code>
556
557
558
559
560
561        void</code>
562    </td>
563
564    <td width="100%">
565      <code>
566      <a href="/reference/android/support/test/uiautomator/UiDevice.html#freezeRotation()">freezeRotation</a>()
567      </code>
568
569        <p>Disables the sensors and freezes the device rotation at its
570 current rotation state.
571
572
573</p>
574
575    </td>
576  </tr>
577
578
579
580  <tr class="api apilevel-" >
581
582
583    <td><code>
584
585
586
587
588
589        String</code>
590    </td>
591
592    <td width="100%">
593      <code>
594      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getCurrentActivityName()">getCurrentActivityName</a>()
595      </code>
596
597        <p><em>
598      This method is deprecated.
599    The results returned should be considered unreliable</em>
600
601
602</p>
603
604    </td>
605  </tr>
606
607
608
609  <tr class="api apilevel-" >
610
611
612    <td><code>
613
614
615
616
617
618        String</code>
619    </td>
620
621    <td width="100%">
622      <code>
623      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getCurrentPackageName()">getCurrentPackageName</a>()
624      </code>
625
626        <p>Retrieves the name of the last package to report accessibility events.
627
628
629</p>
630
631    </td>
632  </tr>
633
634
635
636  <tr class="api apilevel-" >
637
638
639    <td><code>
640
641
642
643
644
645        int</code>
646    </td>
647
648    <td width="100%">
649      <code>
650      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getDisplayHeight()">getDisplayHeight</a>()
651      </code>
652
653        <p>Gets the height of the display, in pixels.
654
655
656</p>
657
658    </td>
659  </tr>
660
661
662
663  <tr class="api apilevel-" >
664
665
666    <td><code>
667
668
669
670
671
672        int</code>
673    </td>
674
675    <td width="100%">
676      <code>
677      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getDisplayRotation()">getDisplayRotation</a>()
678      </code>
679
680        <p>Returns the current rotation of the display, as defined in <code><a href="/reference/android/view/Surface.html">Surface</a></code>
681
682
683</p>
684
685    </td>
686  </tr>
687
688
689
690  <tr class="api apilevel-" >
691
692
693    <td><code>
694
695
696
697
698
699        Point</code>
700    </td>
701
702    <td width="100%">
703      <code>
704      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getDisplaySizeDp()">getDisplaySizeDp</a>()
705      </code>
706
707        <p>Returns the display size in dp (device-independent pixel)
708
709 The returned display size is adjusted per screen rotation.
710
711
712</p>
713
714    </td>
715  </tr>
716
717
718
719  <tr class="api apilevel-" >
720
721
722    <td><code>
723
724
725
726
727
728        int</code>
729    </td>
730
731    <td width="100%">
732      <code>
733      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getDisplayWidth()">getDisplayWidth</a>()
734      </code>
735
736        <p>Gets the width of the display, in pixels.
737
738
739</p>
740
741    </td>
742  </tr>
743
744
745
746  <tr class="api apilevel-" >
747
748
749    <td><code>
750
751
752        static
753
754
755        <a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></code>
756    </td>
757
758    <td width="100%">
759      <code>
760      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getInstance()">getInstance</a>()
761      </code>
762
763        <p><em>
764      This method is deprecated.
765    Should use <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#getInstance(android.app.Instrumentation)">getInstance(Instrumentation)</a></code> instead. This version hides
766 UiDevice's dependency on having an Instrumentation reference and is prone to misuse.</em>
767
768
769</p>
770
771    </td>
772  </tr>
773
774
775
776  <tr class="api apilevel-" >
777
778
779    <td><code>
780
781
782        static
783
784
785        <a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></code>
786    </td>
787
788    <td width="100%">
789      <code>
790      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getInstance(android.app.Instrumentation)">getInstance</a>(Instrumentation instrumentation)
791      </code>
792
793        <p>Retrieves a singleton instance of UiDevice
794
795
796</p>
797
798    </td>
799  </tr>
800
801
802
803  <tr class="api apilevel-" >
804
805
806    <td><code>
807
808
809
810
811
812        String</code>
813    </td>
814
815    <td width="100%">
816      <code>
817      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getLastTraversedText()">getLastTraversedText</a>()
818      </code>
819
820        <p>Retrieves the text from the last UI traversal event received.
821
822
823</p>
824
825    </td>
826  </tr>
827
828
829
830  <tr class="api apilevel-" >
831
832
833    <td><code>
834
835
836
837
838
839        String</code>
840    </td>
841
842    <td width="100%">
843      <code>
844      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getLauncherPackageName()">getLauncherPackageName</a>()
845      </code>
846
847        <p>Retrieves default launcher package name
848
849
850</p>
851
852    </td>
853  </tr>
854
855
856
857  <tr class="api apilevel-" >
858
859
860    <td><code>
861
862
863
864
865
866        String</code>
867    </td>
868
869    <td width="100%">
870      <code>
871      <a href="/reference/android/support/test/uiautomator/UiDevice.html#getProductName()">getProductName</a>()
872      </code>
873
874        <p>Retrieves the product name of the device.
875
876
877</p>
878
879    </td>
880  </tr>
881
882
883
884  <tr class="api apilevel-" >
885
886
887    <td><code>
888
889
890
891
892
893        boolean</code>
894    </td>
895
896    <td width="100%">
897      <code>
898      <a href="/reference/android/support/test/uiautomator/UiDevice.html#hasAnyWatcherTriggered()">hasAnyWatcherTriggered</a>()
899      </code>
900
901        <p>Checks if any registered <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> have triggered.
902
903
904</p>
905
906    </td>
907  </tr>
908
909
910
911  <tr class="api apilevel-" >
912
913
914    <td><code>
915
916
917
918
919
920        boolean</code>
921    </td>
922
923    <td width="100%">
924      <code>
925      <a href="/reference/android/support/test/uiautomator/UiDevice.html#hasObject(android.support.test.uiautomator.BySelector)">hasObject</a>(<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)
926      </code>
927
928        <p>Returns whether there is a match for the given <code>selector</code> criteria.
929
930
931</p>
932
933    </td>
934  </tr>
935
936
937
938  <tr class="api apilevel-" >
939
940
941    <td><code>
942
943
944
945
946
947        boolean</code>
948    </td>
949
950    <td width="100%">
951      <code>
952      <a href="/reference/android/support/test/uiautomator/UiDevice.html#hasWatcherTriggered(java.lang.String)">hasWatcherTriggered</a>(String watcherName)
953      </code>
954
955        <p>Checks if a specific registered  <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> has triggered.
956
957
958</p>
959
960    </td>
961  </tr>
962
963
964
965  <tr class="api apilevel-" >
966
967
968    <td><code>
969
970
971
972
973
974        boolean</code>
975    </td>
976
977    <td width="100%">
978      <code>
979      <a href="/reference/android/support/test/uiautomator/UiDevice.html#isNaturalOrientation()">isNaturalOrientation</a>()
980      </code>
981
982        <p>Check if the device is in its natural orientation.
983
984
985</p>
986
987    </td>
988  </tr>
989
990
991
992  <tr class="api apilevel-" >
993
994
995    <td><code>
996
997
998
999
1000
1001        boolean</code>
1002    </td>
1003
1004    <td width="100%">
1005      <code>
1006      <a href="/reference/android/support/test/uiautomator/UiDevice.html#isScreenOn()">isScreenOn</a>()
1007      </code>
1008
1009        <p>Checks the power manager if the screen is ON.
1010
1011
1012</p>
1013
1014    </td>
1015  </tr>
1016
1017
1018
1019  <tr class="api apilevel-" >
1020
1021
1022    <td><code>
1023
1024
1025
1026
1027
1028        boolean</code>
1029    </td>
1030
1031    <td width="100%">
1032      <code>
1033      <a href="/reference/android/support/test/uiautomator/UiDevice.html#openNotification()">openNotification</a>()
1034      </code>
1035
1036        <p>Opens the notification shade.
1037
1038
1039</p>
1040
1041    </td>
1042  </tr>
1043
1044
1045
1046  <tr class="api apilevel-" >
1047
1048
1049    <td><code>
1050
1051
1052
1053
1054
1055        boolean</code>
1056    </td>
1057
1058    <td width="100%">
1059      <code>
1060      <a href="/reference/android/support/test/uiautomator/UiDevice.html#openQuickSettings()">openQuickSettings</a>()
1061      </code>
1062
1063        <p>Opens the Quick Settings shade.
1064
1065
1066</p>
1067
1068    </td>
1069  </tr>
1070
1071
1072
1073  <tr class="api apilevel-" >
1074
1075
1076    <td><code>
1077
1078
1079
1080
1081        &lt;R&gt;
1082        R</code>
1083    </td>
1084
1085    <td width="100%">
1086      <code>
1087      <a href="/reference/android/support/test/uiautomator/UiDevice.html#performActionAndWait(java.lang.Runnable, android.support.test.uiautomator.EventCondition<R>, long)">performActionAndWait</a>(Runnable action, <a href="/reference/android/support/test/uiautomator/EventCondition.html">EventCondition</a>&lt;R&gt; condition, long timeout)
1088      </code>
1089
1090        <p>Performs the provided <code>action</code> and waits for the <code>condition</code> to be met.
1091
1092
1093</p>
1094
1095    </td>
1096  </tr>
1097
1098
1099
1100  <tr class="api apilevel-" >
1101
1102
1103    <td><code>
1104
1105
1106
1107
1108
1109        boolean</code>
1110    </td>
1111
1112    <td width="100%">
1113      <code>
1114      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressBack()">pressBack</a>()
1115      </code>
1116
1117        <p>Simulates a short press on the BACK button.
1118
1119
1120</p>
1121
1122    </td>
1123  </tr>
1124
1125
1126
1127  <tr class="api apilevel-" >
1128
1129
1130    <td><code>
1131
1132
1133
1134
1135
1136        boolean</code>
1137    </td>
1138
1139    <td width="100%">
1140      <code>
1141      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDPadCenter()">pressDPadCenter</a>()
1142      </code>
1143
1144        <p>Simulates a short press on the CENTER button.
1145
1146
1147</p>
1148
1149    </td>
1150  </tr>
1151
1152
1153
1154  <tr class="api apilevel-" >
1155
1156
1157    <td><code>
1158
1159
1160
1161
1162
1163        boolean</code>
1164    </td>
1165
1166    <td width="100%">
1167      <code>
1168      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDPadDown()">pressDPadDown</a>()
1169      </code>
1170
1171        <p>Simulates a short press on the DOWN button.
1172
1173
1174</p>
1175
1176    </td>
1177  </tr>
1178
1179
1180
1181  <tr class="api apilevel-" >
1182
1183
1184    <td><code>
1185
1186
1187
1188
1189
1190        boolean</code>
1191    </td>
1192
1193    <td width="100%">
1194      <code>
1195      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDPadLeft()">pressDPadLeft</a>()
1196      </code>
1197
1198        <p>Simulates a short press on the LEFT button.
1199
1200
1201</p>
1202
1203    </td>
1204  </tr>
1205
1206
1207
1208  <tr class="api apilevel-" >
1209
1210
1211    <td><code>
1212
1213
1214
1215
1216
1217        boolean</code>
1218    </td>
1219
1220    <td width="100%">
1221      <code>
1222      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDPadRight()">pressDPadRight</a>()
1223      </code>
1224
1225        <p>Simulates a short press on the RIGHT button.
1226
1227
1228</p>
1229
1230    </td>
1231  </tr>
1232
1233
1234
1235  <tr class="api apilevel-" >
1236
1237
1238    <td><code>
1239
1240
1241
1242
1243
1244        boolean</code>
1245    </td>
1246
1247    <td width="100%">
1248      <code>
1249      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDPadUp()">pressDPadUp</a>()
1250      </code>
1251
1252        <p>Simulates a short press on the UP button.
1253
1254
1255</p>
1256
1257    </td>
1258  </tr>
1259
1260
1261
1262  <tr class="api apilevel-" >
1263
1264
1265    <td><code>
1266
1267
1268
1269
1270
1271        boolean</code>
1272    </td>
1273
1274    <td width="100%">
1275      <code>
1276      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressDelete()">pressDelete</a>()
1277      </code>
1278
1279        <p>Simulates a short press on the DELETE key.
1280
1281
1282</p>
1283
1284    </td>
1285  </tr>
1286
1287
1288
1289  <tr class="api apilevel-" >
1290
1291
1292    <td><code>
1293
1294
1295
1296
1297
1298        boolean</code>
1299    </td>
1300
1301    <td width="100%">
1302      <code>
1303      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressEnter()">pressEnter</a>()
1304      </code>
1305
1306        <p>Simulates a short press on the ENTER key.
1307
1308
1309</p>
1310
1311    </td>
1312  </tr>
1313
1314
1315
1316  <tr class="api apilevel-" >
1317
1318
1319    <td><code>
1320
1321
1322
1323
1324
1325        boolean</code>
1326    </td>
1327
1328    <td width="100%">
1329      <code>
1330      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressHome()">pressHome</a>()
1331      </code>
1332
1333        <p>Simulates a short press on the HOME button.
1334
1335
1336</p>
1337
1338    </td>
1339  </tr>
1340
1341
1342
1343  <tr class="api apilevel-" >
1344
1345
1346    <td><code>
1347
1348
1349
1350
1351
1352        boolean</code>
1353    </td>
1354
1355    <td width="100%">
1356      <code>
1357      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressKeyCode(int)">pressKeyCode</a>(int keyCode)
1358      </code>
1359
1360        <p>Simulates a short press using a key code.
1361
1362
1363</p>
1364
1365    </td>
1366  </tr>
1367
1368
1369
1370  <tr class="api apilevel-" >
1371
1372
1373    <td><code>
1374
1375
1376
1377
1378
1379        boolean</code>
1380    </td>
1381
1382    <td width="100%">
1383      <code>
1384      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressKeyCode(int, int)">pressKeyCode</a>(int keyCode, int metaState)
1385      </code>
1386
1387        <p>Simulates a short press using a key code.
1388
1389
1390</p>
1391
1392    </td>
1393  </tr>
1394
1395
1396
1397  <tr class="api apilevel-" >
1398
1399
1400    <td><code>
1401
1402
1403
1404
1405
1406        boolean</code>
1407    </td>
1408
1409    <td width="100%">
1410      <code>
1411      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressMenu()">pressMenu</a>()
1412      </code>
1413
1414        <p>Simulates a short press on the MENU button.
1415
1416
1417</p>
1418
1419    </td>
1420  </tr>
1421
1422
1423
1424  <tr class="api apilevel-" >
1425
1426
1427    <td><code>
1428
1429
1430
1431
1432
1433        boolean</code>
1434    </td>
1435
1436    <td width="100%">
1437      <code>
1438      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressRecentApps()">pressRecentApps</a>()
1439      </code>
1440
1441        <p>Simulates a short press on the Recent Apps button.
1442
1443
1444</p>
1445
1446    </td>
1447  </tr>
1448
1449
1450
1451  <tr class="api apilevel-" >
1452
1453
1454    <td><code>
1455
1456
1457
1458
1459
1460        boolean</code>
1461    </td>
1462
1463    <td width="100%">
1464      <code>
1465      <a href="/reference/android/support/test/uiautomator/UiDevice.html#pressSearch()">pressSearch</a>()
1466      </code>
1467
1468        <p>Simulates a short press on the SEARCH button.
1469
1470
1471</p>
1472
1473    </td>
1474  </tr>
1475
1476
1477
1478  <tr class="api apilevel-" >
1479
1480
1481    <td><code>
1482
1483
1484
1485
1486
1487        void</code>
1488    </td>
1489
1490    <td width="100%">
1491      <code>
1492      <a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher</a>(String name, <a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a> watcher)
1493      </code>
1494
1495        <p>Registers a <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> to run automatically when the testing framework is unable to
1496 find a match using a <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code>.
1497
1498
1499</p>
1500
1501    </td>
1502  </tr>
1503
1504
1505
1506  <tr class="api apilevel-" >
1507
1508
1509    <td><code>
1510
1511
1512
1513
1514
1515        void</code>
1516    </td>
1517
1518    <td width="100%">
1519      <code>
1520      <a href="/reference/android/support/test/uiautomator/UiDevice.html#removeWatcher(java.lang.String)">removeWatcher</a>(String name)
1521      </code>
1522
1523        <p>Removes a previously registered <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code>.
1524
1525
1526</p>
1527
1528    </td>
1529  </tr>
1530
1531
1532
1533  <tr class="api apilevel-" >
1534
1535
1536    <td><code>
1537
1538
1539
1540
1541
1542        void</code>
1543    </td>
1544
1545    <td width="100%">
1546      <code>
1547      <a href="/reference/android/support/test/uiautomator/UiDevice.html#resetWatcherTriggers()">resetWatcherTriggers</a>()
1548      </code>
1549
1550        <p>Resets a <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> that has been triggered.
1551
1552
1553</p>
1554
1555    </td>
1556  </tr>
1557
1558
1559
1560  <tr class="api apilevel-" >
1561
1562
1563    <td><code>
1564
1565
1566
1567
1568
1569        void</code>
1570    </td>
1571
1572    <td width="100%">
1573      <code>
1574      <a href="/reference/android/support/test/uiautomator/UiDevice.html#runWatchers()">runWatchers</a>()
1575      </code>
1576
1577        <p>This method forces all registered watchers to run.
1578
1579
1580</p>
1581
1582    </td>
1583  </tr>
1584
1585
1586
1587  <tr class="api apilevel-" >
1588
1589
1590    <td><code>
1591
1592
1593
1594
1595
1596        void</code>
1597    </td>
1598
1599    <td width="100%">
1600      <code>
1601      <a href="/reference/android/support/test/uiautomator/UiDevice.html#setCompressedLayoutHeirarchy(boolean)">setCompressedLayoutHeirarchy</a>(boolean compressed)
1602      </code>
1603
1604        <p>Enables or disables layout hierarchy compression.
1605
1606
1607</p>
1608
1609    </td>
1610  </tr>
1611
1612
1613
1614  <tr class="api apilevel-" >
1615
1616
1617    <td><code>
1618
1619
1620
1621
1622
1623        void</code>
1624    </td>
1625
1626    <td width="100%">
1627      <code>
1628      <a href="/reference/android/support/test/uiautomator/UiDevice.html#setOrientationLeft()">setOrientationLeft</a>()
1629      </code>
1630
1631        <p>Simulates orienting the device to the left and also freezes rotation
1632 by disabling the sensors.
1633
1634
1635</p>
1636
1637    </td>
1638  </tr>
1639
1640
1641
1642  <tr class="api apilevel-" >
1643
1644
1645    <td><code>
1646
1647
1648
1649
1650
1651        void</code>
1652    </td>
1653
1654    <td width="100%">
1655      <code>
1656      <a href="/reference/android/support/test/uiautomator/UiDevice.html#setOrientationNatural()">setOrientationNatural</a>()
1657      </code>
1658
1659        <p>Simulates orienting the device into its natural orientation and also freezes rotation
1660 by disabling the sensors.
1661
1662
1663</p>
1664
1665    </td>
1666  </tr>
1667
1668
1669
1670  <tr class="api apilevel-" >
1671
1672
1673    <td><code>
1674
1675
1676
1677
1678
1679        void</code>
1680    </td>
1681
1682    <td width="100%">
1683      <code>
1684      <a href="/reference/android/support/test/uiautomator/UiDevice.html#setOrientationRight()">setOrientationRight</a>()
1685      </code>
1686
1687        <p>Simulates orienting the device to the right and also freezes rotation
1688 by disabling the sensors.
1689
1690
1691</p>
1692
1693    </td>
1694  </tr>
1695
1696
1697
1698  <tr class="api apilevel-" >
1699
1700
1701    <td><code>
1702
1703
1704
1705
1706
1707        void</code>
1708    </td>
1709
1710    <td width="100%">
1711      <code>
1712      <a href="/reference/android/support/test/uiautomator/UiDevice.html#sleep()">sleep</a>()
1713      </code>
1714
1715        <p>This method simply presses the power button if the screen is ON else
1716 it does nothing if the screen is already OFF.
1717
1718
1719</p>
1720
1721    </td>
1722  </tr>
1723
1724
1725
1726  <tr class="api apilevel-" >
1727
1728
1729    <td><code>
1730
1731
1732
1733
1734
1735        boolean</code>
1736    </td>
1737
1738    <td width="100%">
1739      <code>
1740      <a href="/reference/android/support/test/uiautomator/UiDevice.html#swipe(int, int, int, int, int)">swipe</a>(int startX, int startY, int endX, int endY, int steps)
1741      </code>
1742
1743        <p>Performs a swipe from one coordinate to another using the number of steps
1744 to determine smoothness and speed.
1745
1746
1747</p>
1748
1749    </td>
1750  </tr>
1751
1752
1753
1754  <tr class="api apilevel-" >
1755
1756
1757    <td><code>
1758
1759
1760
1761
1762
1763        boolean</code>
1764    </td>
1765
1766    <td width="100%">
1767      <code>
1768      <a href="/reference/android/support/test/uiautomator/UiDevice.html#swipe(android.graphics.Point[], int)">swipe</a>(Point[] segments, int segmentSteps)
1769      </code>
1770
1771        <p>Performs a swipe between points in the Point array.
1772
1773
1774</p>
1775
1776    </td>
1777  </tr>
1778
1779
1780
1781  <tr class="api apilevel-" >
1782
1783
1784    <td><code>
1785
1786
1787
1788
1789
1790        boolean</code>
1791    </td>
1792
1793    <td width="100%">
1794      <code>
1795      <a href="/reference/android/support/test/uiautomator/UiDevice.html#takeScreenshot(java.io.File, float, int)">takeScreenshot</a>(File storePath, float scale, int quality)
1796      </code>
1797
1798        <p>Take a screenshot of current window and store it as PNG
1799
1800 The screenshot is adjusted per screen rotation
1801
1802
1803</p>
1804
1805    </td>
1806  </tr>
1807
1808
1809
1810  <tr class="api apilevel-" >
1811
1812
1813    <td><code>
1814
1815
1816
1817
1818
1819        boolean</code>
1820    </td>
1821
1822    <td width="100%">
1823      <code>
1824      <a href="/reference/android/support/test/uiautomator/UiDevice.html#takeScreenshot(java.io.File)">takeScreenshot</a>(File storePath)
1825      </code>
1826
1827        <p>Take a screenshot of current window and store it as PNG
1828
1829 Default scale of 1.0f (original size) and 90% quality is used
1830 The screenshot is adjusted per screen rotation
1831
1832
1833</p>
1834
1835    </td>
1836  </tr>
1837
1838
1839
1840  <tr class="api apilevel-" >
1841
1842
1843    <td><code>
1844
1845
1846
1847
1848
1849        void</code>
1850    </td>
1851
1852    <td width="100%">
1853      <code>
1854      <a href="/reference/android/support/test/uiautomator/UiDevice.html#unfreezeRotation()">unfreezeRotation</a>()
1855      </code>
1856
1857        <p>Re-enables the sensors and un-freezes the device rotation allowing its contents
1858 to rotate with the device physical rotation.
1859
1860
1861</p>
1862
1863    </td>
1864  </tr>
1865
1866
1867
1868  <tr class="api apilevel-" >
1869
1870
1871    <td><code>
1872
1873
1874
1875
1876        &lt;R&gt;
1877        R</code>
1878    </td>
1879
1880    <td width="100%">
1881      <code>
1882      <a href="/reference/android/support/test/uiautomator/UiDevice.html#wait(android.support.test.uiautomator.SearchCondition<R>, long)">wait</a>(<a href="/reference/android/support/test/uiautomator/SearchCondition.html">SearchCondition</a>&lt;R&gt; condition, long timeout)
1883      </code>
1884
1885        <p>Waits for given the <code>condition</code> to be met.
1886
1887
1888</p>
1889
1890    </td>
1891  </tr>
1892
1893
1894
1895  <tr class="api apilevel-" >
1896
1897
1898    <td><code>
1899
1900
1901
1902
1903
1904        void</code>
1905    </td>
1906
1907    <td width="100%">
1908      <code>
1909      <a href="/reference/android/support/test/uiautomator/UiDevice.html#waitForIdle(long)">waitForIdle</a>(long timeout)
1910      </code>
1911
1912        <p>Waits for the current application to idle.
1913
1914
1915</p>
1916
1917    </td>
1918  </tr>
1919
1920
1921
1922  <tr class="api apilevel-" >
1923
1924
1925    <td><code>
1926
1927
1928
1929
1930
1931        void</code>
1932    </td>
1933
1934    <td width="100%">
1935      <code>
1936      <a href="/reference/android/support/test/uiautomator/UiDevice.html#waitForIdle()">waitForIdle</a>()
1937      </code>
1938
1939        <p>Waits for the current application to idle.
1940
1941
1942</p>
1943
1944    </td>
1945  </tr>
1946
1947
1948
1949  <tr class="api apilevel-" >
1950
1951
1952    <td><code>
1953
1954
1955
1956
1957
1958        boolean</code>
1959    </td>
1960
1961    <td width="100%">
1962      <code>
1963      <a href="/reference/android/support/test/uiautomator/UiDevice.html#waitForWindowUpdate(java.lang.String, long)">waitForWindowUpdate</a>(String packageName, long timeout)
1964      </code>
1965
1966        <p>Waits for a window content update event to occur.
1967
1968
1969</p>
1970
1971    </td>
1972  </tr>
1973
1974
1975
1976  <tr class="api apilevel-" >
1977
1978
1979    <td><code>
1980
1981
1982
1983
1984
1985        void</code>
1986    </td>
1987
1988    <td width="100%">
1989      <code>
1990      <a href="/reference/android/support/test/uiautomator/UiDevice.html#wakeUp()">wakeUp</a>()
1991      </code>
1992
1993        <p>This method simulates pressing the power button if the screen is OFF else
1994 it does nothing if the screen is already ON.
1995
1996
1997</p>
1998
1999    </td>
2000  </tr>
2001
2002
2003
2004</table>
2005
2006
2007
2008
2009
2010
2011
2012<!-- ========== METHOD SUMMARY =========== -->
2013<table id="inhmethods" class="methods inhtable">
2014<tr><th><h3>Inherited methods</h3></th></tr>
2015
2016
2017<tr class="api apilevel-" >
2018<td colspan="2">
2019
2020  <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed"
2021          ><img height="34" id="inherited-methods-java.lang.Object-trigger"
2022          src="/assets/images/styles/disclosure_down.png"
2023          class="jd-expando-trigger-img" /></a>From
2024class
2025<code>
2026
2027    java.lang.Object
2028
2029</code>
2030<div id="inherited-methods-java.lang.Object">
2031  <div id="inherited-methods-java.lang.Object-list"
2032        class="jd-inheritedlinks">
2033  </div>
2034  <div id="inherited-methods-java.lang.Object-summary" style="display: none;">
2035    <table class="jd-sumtable-expando responsive">
2036
2037
2038
2039
2040  <tr class="api apilevel-" >
2041
2042
2043    <td><code>
2044
2045
2046
2047
2048
2049        Object</code>
2050    </td>
2051
2052    <td width="100%">
2053      <code>
2054      clone()
2055      </code>
2056
2057    </td>
2058  </tr>
2059
2060
2061
2062  <tr class="api apilevel-" >
2063
2064
2065    <td><code>
2066
2067
2068
2069
2070
2071        boolean</code>
2072    </td>
2073
2074    <td width="100%">
2075      <code>
2076      equals(Object arg0)
2077      </code>
2078
2079    </td>
2080  </tr>
2081
2082
2083
2084  <tr class="api apilevel-" >
2085
2086
2087    <td><code>
2088
2089
2090
2091
2092
2093        void</code>
2094    </td>
2095
2096    <td width="100%">
2097      <code>
2098      finalize()
2099      </code>
2100
2101    </td>
2102  </tr>
2103
2104
2105
2106  <tr class="api apilevel-" >
2107
2108
2109    <td><code>
2110
2111
2112
2113        final
2114
2115        Class&lt;?&gt;</code>
2116    </td>
2117
2118    <td width="100%">
2119      <code>
2120      getClass()
2121      </code>
2122
2123    </td>
2124  </tr>
2125
2126
2127
2128  <tr class="api apilevel-" >
2129
2130
2131    <td><code>
2132
2133
2134
2135
2136
2137        int</code>
2138    </td>
2139
2140    <td width="100%">
2141      <code>
2142      hashCode()
2143      </code>
2144
2145    </td>
2146  </tr>
2147
2148
2149
2150  <tr class="api apilevel-" >
2151
2152
2153    <td><code>
2154
2155
2156
2157        final
2158
2159        void</code>
2160    </td>
2161
2162    <td width="100%">
2163      <code>
2164      notify()
2165      </code>
2166
2167    </td>
2168  </tr>
2169
2170
2171
2172  <tr class="api apilevel-" >
2173
2174
2175    <td><code>
2176
2177
2178
2179        final
2180
2181        void</code>
2182    </td>
2183
2184    <td width="100%">
2185      <code>
2186      notifyAll()
2187      </code>
2188
2189    </td>
2190  </tr>
2191
2192
2193
2194  <tr class="api apilevel-" >
2195
2196
2197    <td><code>
2198
2199
2200
2201
2202
2203        String</code>
2204    </td>
2205
2206    <td width="100%">
2207      <code>
2208      toString()
2209      </code>
2210
2211    </td>
2212  </tr>
2213
2214
2215
2216  <tr class="api apilevel-" >
2217
2218
2219    <td><code>
2220
2221
2222
2223        final
2224
2225        void</code>
2226    </td>
2227
2228    <td width="100%">
2229      <code>
2230      wait(long arg0, int arg1)
2231      </code>
2232
2233    </td>
2234  </tr>
2235
2236
2237
2238  <tr class="api apilevel-" >
2239
2240
2241    <td><code>
2242
2243
2244
2245        final
2246
2247        void</code>
2248    </td>
2249
2250    <td width="100%">
2251      <code>
2252      wait(long arg0)
2253      </code>
2254
2255    </td>
2256  </tr>
2257
2258
2259
2260  <tr class="api apilevel-" >
2261
2262
2263    <td><code>
2264
2265
2266
2267        final
2268
2269        void</code>
2270    </td>
2271
2272    <td width="100%">
2273      <code>
2274      wait()
2275      </code>
2276
2277    </td>
2278  </tr>
2279
2280
2281
2282    </table>
2283  </div>
2284</div>
2285</td></tr>
2286
2287
2288</table>
2289
2290
2291
2292<!-- XML Attributes -->
2293
2294
2295<!-- Enum Values -->
2296
2297
2298<!-- Constants -->
2299
2300
2301<!-- Fields -->
2302
2303
2304<!-- Public ctors -->
2305
2306
2307
2308<!-- ========= CONSTRUCTOR DETAIL ======== -->
2309<!-- Protected ctors -->
2310
2311
2312
2313<!-- ========= METHOD DETAIL ======== -->
2314<!-- Public methdos -->
2315
2316<h2 class="api-section">Public methods</h2>
2317
2318
2319
2320<A NAME="clearLastTraversedText()"></A>
2321
2322<div class="api apilevel-">
2323    <h3 class="api-name">clearLastTraversedText</h3>
2324    <div class="api-level">
2325      <div></div>
2326
2327
2328
2329    </div>
2330<pre class="api-signature no-pretty-print">
2331void clearLastTraversedText ()</pre>
2332
2333
2334
2335
2336  <p>Clears the text from the last UI traversal event.
2337 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#getLastTraversedText()">getLastTraversedText()</a></code>.</p>
2338
2339
2340</div>
2341
2342
2343<A NAME="click(int, int)"></A>
2344
2345<div class="api apilevel-">
2346    <h3 class="api-name">click</h3>
2347    <div class="api-level">
2348      <div></div>
2349
2350
2351
2352    </div>
2353<pre class="api-signature no-pretty-print">
2354boolean click (int x,
2355                int y)</pre>
2356
2357
2358
2359
2360  <p>Perform a click at arbitrary coordinates specified by the user</p>
2361
2362    <table class="responsive">
2363    <tr><th colspan=2>Parameters</th></tr>
2364      <tr>
2365        <td><code>x</code></td>
2366        <td width="100%">
2367          <code>int</code>:
2368          coordinate</td>
2369      </tr>
2370      <tr>
2371        <td><code>y</code></td>
2372        <td width="100%">
2373          <code>int</code>:
2374          coordinate</td>
2375      </tr>
2376    </table>
2377    <table class="responsive">
2378      <tr><th colspan=2>Returns</th></tr>
2379      <tr>
2380        <td><code>boolean</code></td>
2381        <td width="100%">true if the click succeeded else false</td>
2382      </tr>
2383    </table>
2384
2385</div>
2386
2387
2388<A NAME="drag(int, int, int, int, int)"></A>
2389
2390<div class="api apilevel-">
2391    <h3 class="api-name">drag</h3>
2392    <div class="api-level">
2393      <div></div>
2394
2395
2396
2397    </div>
2398<pre class="api-signature no-pretty-print">
2399boolean drag (int startX,
2400                int startY,
2401                int endX,
2402                int endY,
2403                int steps)</pre>
2404
2405
2406
2407
2408  <p>Performs a swipe from one coordinate to another coordinate. You can control
2409 the smoothness and speed of the swipe by specifying the number of steps.
2410 Each step execution is throttled to 5 milliseconds per step, so for a 100
2411 steps, the swipe will take around 0.5 seconds to complete.</p>
2412
2413    <table class="responsive">
2414    <tr><th colspan=2>Parameters</th></tr>
2415      <tr>
2416        <td><code>startX</code></td>
2417        <td width="100%">
2418          <code>int</code>:
2419          X-axis value for the starting coordinate</td>
2420      </tr>
2421      <tr>
2422        <td><code>startY</code></td>
2423        <td width="100%">
2424          <code>int</code>:
2425          Y-axis value for the starting coordinate</td>
2426      </tr>
2427      <tr>
2428        <td><code>endX</code></td>
2429        <td width="100%">
2430          <code>int</code>:
2431          X-axis value for the ending coordinate</td>
2432      </tr>
2433      <tr>
2434        <td><code>endY</code></td>
2435        <td width="100%">
2436          <code>int</code>:
2437          Y-axis value for the ending coordinate</td>
2438      </tr>
2439      <tr>
2440        <td><code>steps</code></td>
2441        <td width="100%">
2442          <code>int</code>:
2443          is the number of steps for the swipe action</td>
2444      </tr>
2445    </table>
2446    <table class="responsive">
2447      <tr><th colspan=2>Returns</th></tr>
2448      <tr>
2449        <td><code>boolean</code></td>
2450        <td width="100%">true if swipe is performed, false if the operation fails
2451 or the coordinates are invalid</td>
2452      </tr>
2453    </table>
2454
2455</div>
2456
2457
2458<A NAME="dumpWindowHierarchy(java.io.File)"></A>
2459
2460<div class="api apilevel-">
2461    <h3 class="api-name">dumpWindowHierarchy</h3>
2462    <div class="api-level">
2463      <div></div>
2464
2465
2466
2467    </div>
2468<pre class="api-signature no-pretty-print">
2469void dumpWindowHierarchy (File dest)</pre>
2470
2471
2472
2473
2474  <p>Dump the current window hierarchy to a <code><a href="/reference/java/io/File.html">File</a></code>.</p>
2475    <table class="responsive">
2476    <tr><th colspan=2>Parameters</th></tr>
2477      <tr>
2478        <td><code>dest</code></td>
2479        <td width="100%">
2480          <code>File</code>:
2481          The file in which to store the window hierarchy information.</td>
2482      </tr>
2483    </table>
2484      <table class="responsive">
2485      <tr><th colspan=2>Throws</th></tr>
2486        <tr>
2487          <td><code>IOException</code></td>
2488          <td width="100%"></td>
2489        </tr>
2490      </table>
2491
2492
2493</div>
2494
2495
2496<A NAME="dumpWindowHierarchy(java.io.OutputStream)"></A>
2497
2498<div class="api apilevel-">
2499    <h3 class="api-name">dumpWindowHierarchy</h3>
2500    <div class="api-level">
2501      <div></div>
2502
2503
2504
2505    </div>
2506<pre class="api-signature no-pretty-print">
2507void dumpWindowHierarchy (OutputStream out)</pre>
2508
2509
2510
2511
2512  <p>Dump the current window hierarchy to an <code><a href="/reference/java/io/OutputStream.html">OutputStream</a></code>.</p>
2513    <table class="responsive">
2514    <tr><th colspan=2>Parameters</th></tr>
2515      <tr>
2516        <td><code>out</code></td>
2517        <td width="100%">
2518          <code>OutputStream</code>:
2519          The output stream that the window hierarchy information is written to.</td>
2520      </tr>
2521    </table>
2522      <table class="responsive">
2523      <tr><th colspan=2>Throws</th></tr>
2524        <tr>
2525          <td><code>IOException</code></td>
2526          <td width="100%"></td>
2527        </tr>
2528      </table>
2529
2530
2531</div>
2532
2533
2534<A NAME="dumpWindowHierarchy(java.lang.String)"></A>
2535
2536<div class="api apilevel-">
2537    <h3 class="api-name">dumpWindowHierarchy</h3>
2538    <div class="api-level">
2539      <div></div>
2540
2541
2542
2543    </div>
2544<pre class="api-signature no-pretty-print">
2545void dumpWindowHierarchy (String fileName)</pre>
2546
2547
2548
2549    <p>
2550  <p class="caution"><strong>
2551      This method is deprecated.</strong><br/>
2552    Use <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.File)">dumpWindowHierarchy(File)</a></code> or
2553     <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#dumpWindowHierarchy(java.io.OutputStream)">dumpWindowHierarchy(OutputStream)</a></code> instead.
2554
2555  </p>
2556  <p>Helper method used for debugging to dump the current window's layout hierarchy.
2557 Relative file paths are stored the application's internal private storage location.</p>
2558
2559
2560</div>
2561
2562
2563<A NAME="findObject(android.support.test.uiautomator.BySelector)"></A>
2564
2565<div class="api apilevel-">
2566    <h3 class="api-name">findObject</h3>
2567    <div class="api-level">
2568      <div></div>
2569
2570
2571
2572    </div>
2573<pre class="api-signature no-pretty-print">
2574<a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a> findObject (<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)</pre>
2575
2576
2577
2578
2579  <p>Returns the first object to match the <code>selector</code> criteria. </p>
2580    <table class="responsive">
2581    <tr><th colspan=2>Parameters</th></tr>
2582      <tr>
2583        <td><code>selector</code></td>
2584        <td width="100%">
2585          <code>BySelector</code>
2586          <!-- no parameter comment --></td>
2587      </tr>
2588    </table>
2589    <table class="responsive">
2590      <tr><th colspan=2>Returns</th></tr>
2591      <tr>
2592        <td><code><a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a></code></td>
2593        <td width="100%"><!-- no returns description in source --></td>
2594      </tr>
2595    </table>
2596
2597</div>
2598
2599
2600<A NAME="findObject(android.support.test.uiautomator.UiSelector)"></A>
2601
2602<div class="api apilevel-">
2603    <h3 class="api-name">findObject</h3>
2604    <div class="api-level">
2605      <div></div>
2606
2607
2608
2609    </div>
2610<pre class="api-signature no-pretty-print">
2611<a href="/reference/android/support/test/uiautomator/UiObject.html">UiObject</a> findObject (<a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a> selector)</pre>
2612
2613
2614
2615
2616  <p>Returns a UiObject which represents a view that matches the specified selector criteria.</p>
2617    <table class="responsive">
2618      <tr><th colspan=2>Returns</th></tr>
2619      <tr>
2620        <td><code><a href="/reference/android/support/test/uiautomator/UiObject.html">UiObject</a></code></td>
2621        <td width="100%">UiObject object
2622</td>
2623      </tr>
2624    </table>
2625
2626</div>
2627
2628
2629<A NAME="findObjects(android.support.test.uiautomator.BySelector)"></A>
2630
2631<div class="api apilevel-">
2632    <h3 class="api-name">findObjects</h3>
2633    <div class="api-level">
2634      <div></div>
2635
2636
2637
2638    </div>
2639<pre class="api-signature no-pretty-print">
2640List&lt;<a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a>&gt; findObjects (<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)</pre>
2641
2642
2643
2644
2645  <p>Returns all objects that match the <code>selector</code> criteria. </p>
2646    <table class="responsive">
2647    <tr><th colspan=2>Parameters</th></tr>
2648      <tr>
2649        <td><code>selector</code></td>
2650        <td width="100%">
2651          <code>BySelector</code>
2652          <!-- no parameter comment --></td>
2653      </tr>
2654    </table>
2655    <table class="responsive">
2656      <tr><th colspan=2>Returns</th></tr>
2657      <tr>
2658        <td><code>List&lt;<a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a>&gt;</code></td>
2659        <td width="100%"><!-- no returns description in source --></td>
2660      </tr>
2661    </table>
2662
2663</div>
2664
2665
2666<A NAME="freezeRotation()"></A>
2667
2668<div class="api apilevel-">
2669    <h3 class="api-name">freezeRotation</h3>
2670    <div class="api-level">
2671      <div></div>
2672
2673
2674
2675    </div>
2676<pre class="api-signature no-pretty-print">
2677void freezeRotation ()</pre>
2678
2679
2680
2681
2682  <p>Disables the sensors and freezes the device rotation at its
2683 current rotation state.</p>
2684
2685      <table class="responsive">
2686      <tr><th colspan=2>Throws</th></tr>
2687        <tr>
2688          <td><code></code></td>
2689          <td width="100%">RemoteException</td>
2690        </tr>
2691        <tr>
2692          <td><code>RemoteException</code></td>
2693          <td width="100%"></td>
2694        </tr>
2695      </table>
2696
2697
2698</div>
2699
2700
2701<A NAME="getCurrentActivityName()"></A>
2702
2703<div class="api apilevel-">
2704    <h3 class="api-name">getCurrentActivityName</h3>
2705    <div class="api-level">
2706      <div></div>
2707
2708
2709
2710    </div>
2711<pre class="api-signature no-pretty-print">
2712String getCurrentActivityName ()</pre>
2713
2714
2715
2716    <p>
2717  <p class="caution"><strong>
2718      This method is deprecated.</strong><br/>
2719    The results returned should be considered unreliable
2720  </p>
2721  <p>Retrieves the last activity to report accessibility events.</p>
2722
2723    <table class="responsive">
2724      <tr><th colspan=2>Returns</th></tr>
2725      <tr>
2726        <td><code>String</code></td>
2727        <td width="100%">String name of activity</td>
2728      </tr>
2729    </table>
2730
2731</div>
2732
2733
2734<A NAME="getCurrentPackageName()"></A>
2735
2736<div class="api apilevel-">
2737    <h3 class="api-name">getCurrentPackageName</h3>
2738    <div class="api-level">
2739      <div></div>
2740
2741
2742
2743    </div>
2744<pre class="api-signature no-pretty-print">
2745String getCurrentPackageName ()</pre>
2746
2747
2748
2749
2750  <p>Retrieves the name of the last package to report accessibility events.</p>
2751
2752    <table class="responsive">
2753      <tr><th colspan=2>Returns</th></tr>
2754      <tr>
2755        <td><code>String</code></td>
2756        <td width="100%">String name of package</td>
2757      </tr>
2758    </table>
2759
2760</div>
2761
2762
2763<A NAME="getDisplayHeight()"></A>
2764
2765<div class="api apilevel-">
2766    <h3 class="api-name">getDisplayHeight</h3>
2767    <div class="api-level">
2768      <div></div>
2769
2770
2771
2772    </div>
2773<pre class="api-signature no-pretty-print">
2774int getDisplayHeight ()</pre>
2775
2776
2777
2778
2779  <p>Gets the height of the display, in pixels. The size is adjusted based
2780 on the current orientation of the display.</p>
2781
2782    <table class="responsive">
2783      <tr><th colspan=2>Returns</th></tr>
2784      <tr>
2785        <td><code>int</code></td>
2786        <td width="100%">height in pixels or zero on failure</td>
2787      </tr>
2788    </table>
2789
2790</div>
2791
2792
2793<A NAME="getDisplayRotation()"></A>
2794
2795<div class="api apilevel-">
2796    <h3 class="api-name">getDisplayRotation</h3>
2797    <div class="api-level">
2798      <div></div>
2799
2800
2801
2802    </div>
2803<pre class="api-signature no-pretty-print">
2804int getDisplayRotation ()</pre>
2805
2806
2807
2808
2809  <p>Returns the current rotation of the display, as defined in <code><a href="/reference/android/view/Surface.html">Surface</a></code></p>
2810
2811    <table class="responsive">
2812      <tr><th colspan=2>Returns</th></tr>
2813      <tr>
2814        <td><code>int</code></td>
2815        <td width="100%"><!-- no returns description in source --></td>
2816      </tr>
2817    </table>
2818
2819</div>
2820
2821
2822<A NAME="getDisplaySizeDp()"></A>
2823
2824<div class="api apilevel-">
2825    <h3 class="api-name">getDisplaySizeDp</h3>
2826    <div class="api-level">
2827      <div></div>
2828
2829
2830
2831    </div>
2832<pre class="api-signature no-pretty-print">
2833Point getDisplaySizeDp ()</pre>
2834
2835
2836
2837
2838  <p>Returns the display size in dp (device-independent pixel)
2839
2840 The returned display size is adjusted per screen rotation. Also this will return the actual
2841 size of the screen, rather than adjusted per system decorations (like status bar).</p>
2842    <table class="responsive">
2843      <tr><th colspan=2>Returns</th></tr>
2844      <tr>
2845        <td><code>Point</code></td>
2846        <td width="100%">a Point containing the display size in dp
2847</td>
2848      </tr>
2849    </table>
2850
2851</div>
2852
2853
2854<A NAME="getDisplayWidth()"></A>
2855
2856<div class="api apilevel-">
2857    <h3 class="api-name">getDisplayWidth</h3>
2858    <div class="api-level">
2859      <div></div>
2860
2861
2862
2863    </div>
2864<pre class="api-signature no-pretty-print">
2865int getDisplayWidth ()</pre>
2866
2867
2868
2869
2870  <p>Gets the width of the display, in pixels. The width and height details
2871 are reported based on the current orientation of the display.</p>
2872
2873    <table class="responsive">
2874      <tr><th colspan=2>Returns</th></tr>
2875      <tr>
2876        <td><code>int</code></td>
2877        <td width="100%">width in pixels or zero on failure</td>
2878      </tr>
2879    </table>
2880
2881</div>
2882
2883
2884<A NAME="getInstance()"></A>
2885
2886<div class="api apilevel-">
2887    <h3 class="api-name">getInstance</h3>
2888    <div class="api-level">
2889      <div></div>
2890
2891
2892
2893    </div>
2894<pre class="api-signature no-pretty-print">
2895<a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a> getInstance ()</pre>
2896
2897
2898
2899    <p>
2900  <p class="caution"><strong>
2901      This method is deprecated.</strong><br/>
2902    Should use <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#getInstance(android.app.Instrumentation)">getInstance(Instrumentation)</a></code> instead. This version hides
2903 UiDevice's dependency on having an Instrumentation reference and is prone to misuse.
2904  </p>
2905  <p>Retrieves a singleton instance of UiDevice</p>
2906
2907    <table class="responsive">
2908      <tr><th colspan=2>Returns</th></tr>
2909      <tr>
2910        <td><code><a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></code></td>
2911        <td width="100%">UiDevice instance</td>
2912      </tr>
2913    </table>
2914
2915</div>
2916
2917
2918<A NAME="getInstance(android.app.Instrumentation)"></A>
2919
2920<div class="api apilevel-">
2921    <h3 class="api-name">getInstance</h3>
2922    <div class="api-level">
2923      <div></div>
2924
2925
2926
2927    </div>
2928<pre class="api-signature no-pretty-print">
2929<a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a> getInstance (Instrumentation instrumentation)</pre>
2930
2931
2932
2933
2934  <p>Retrieves a singleton instance of UiDevice</p>
2935    <table class="responsive">
2936    <tr><th colspan=2>Parameters</th></tr>
2937      <tr>
2938        <td><code>instrumentation</code></td>
2939        <td width="100%">
2940          <code>Instrumentation</code>
2941          <!-- no parameter comment --></td>
2942      </tr>
2943    </table>
2944    <table class="responsive">
2945      <tr><th colspan=2>Returns</th></tr>
2946      <tr>
2947        <td><code><a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></code></td>
2948        <td width="100%">UiDevice instance
2949</td>
2950      </tr>
2951    </table>
2952
2953</div>
2954
2955
2956<A NAME="getLastTraversedText()"></A>
2957
2958<div class="api apilevel-">
2959    <h3 class="api-name">getLastTraversedText</h3>
2960    <div class="api-level">
2961      <div></div>
2962
2963
2964
2965    </div>
2966<pre class="api-signature no-pretty-print">
2967String getLastTraversedText ()</pre>
2968
2969
2970
2971
2972  <p>Retrieves the text from the last UI traversal event received.
2973
2974 You can use this method to read the contents in a WebView container
2975 because the accessibility framework fires events
2976 as each text is highlighted. You can write a test to perform
2977 directional arrow presses to focus on different elements inside a WebView,
2978 and call this method to get the text from each traversed element.
2979 If you are testing a view container that can return a reference to a
2980 Document Object Model (DOM) object, your test should use the view's
2981 DOM instead.</p>
2982
2983    <table class="responsive">
2984      <tr><th colspan=2>Returns</th></tr>
2985      <tr>
2986        <td><code>String</code></td>
2987        <td width="100%">text of the last traversal event, else return an empty string</td>
2988      </tr>
2989    </table>
2990
2991</div>
2992
2993
2994<A NAME="getLauncherPackageName()"></A>
2995
2996<div class="api apilevel-">
2997    <h3 class="api-name">getLauncherPackageName</h3>
2998    <div class="api-level">
2999      <div></div>
3000
3001
3002
3003    </div>
3004<pre class="api-signature no-pretty-print">
3005String getLauncherPackageName ()</pre>
3006
3007
3008
3009
3010  <p>Retrieves default launcher package name</p>
3011    <table class="responsive">
3012      <tr><th colspan=2>Returns</th></tr>
3013      <tr>
3014        <td><code>String</code></td>
3015        <td width="100%">package name of the default launcher
3016</td>
3017      </tr>
3018    </table>
3019
3020</div>
3021
3022
3023<A NAME="getProductName()"></A>
3024
3025<div class="api apilevel-">
3026    <h3 class="api-name">getProductName</h3>
3027    <div class="api-level">
3028      <div></div>
3029
3030
3031
3032    </div>
3033<pre class="api-signature no-pretty-print">
3034String getProductName ()</pre>
3035
3036
3037
3038
3039  <p>Retrieves the product name of the device.
3040
3041 This method provides information on what type of device the test is running on. This value is
3042 the same as returned by invoking #adb shell getprop ro.product.name.</p>
3043
3044    <table class="responsive">
3045      <tr><th colspan=2>Returns</th></tr>
3046      <tr>
3047        <td><code>String</code></td>
3048        <td width="100%">product name of the device</td>
3049      </tr>
3050    </table>
3051
3052</div>
3053
3054
3055<A NAME="hasAnyWatcherTriggered()"></A>
3056
3057<div class="api apilevel-">
3058    <h3 class="api-name">hasAnyWatcherTriggered</h3>
3059    <div class="api-level">
3060      <div></div>
3061
3062
3063
3064    </div>
3065<pre class="api-signature no-pretty-print">
3066boolean hasAnyWatcherTriggered ()</pre>
3067
3068
3069
3070
3071  <p>Checks if any registered <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> have triggered.
3072
3073 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code>
3074 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#hasWatcherTriggered(java.lang.String)">hasWatcherTriggered(String)</a></code></p>
3075
3076    <table class="responsive">
3077      <tr><th colspan=2>Returns</th></tr>
3078      <tr>
3079        <td><code>boolean</code></td>
3080        <td width="100%"><!-- no returns description in source --></td>
3081      </tr>
3082    </table>
3083
3084</div>
3085
3086
3087<A NAME="hasObject(android.support.test.uiautomator.BySelector)"></A>
3088
3089<div class="api apilevel-">
3090    <h3 class="api-name">hasObject</h3>
3091    <div class="api-level">
3092      <div></div>
3093
3094
3095
3096    </div>
3097<pre class="api-signature no-pretty-print">
3098boolean hasObject (<a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a> selector)</pre>
3099
3100
3101
3102
3103  <p>Returns whether there is a match for the given <code>selector</code> criteria. </p>
3104    <table class="responsive">
3105    <tr><th colspan=2>Parameters</th></tr>
3106      <tr>
3107        <td><code>selector</code></td>
3108        <td width="100%">
3109          <code>BySelector</code>
3110          <!-- no parameter comment --></td>
3111      </tr>
3112    </table>
3113    <table class="responsive">
3114      <tr><th colspan=2>Returns</th></tr>
3115      <tr>
3116        <td><code>boolean</code></td>
3117        <td width="100%"><!-- no returns description in source --></td>
3118      </tr>
3119    </table>
3120
3121</div>
3122
3123
3124<A NAME="hasWatcherTriggered(java.lang.String)"></A>
3125
3126<div class="api apilevel-">
3127    <h3 class="api-name">hasWatcherTriggered</h3>
3128    <div class="api-level">
3129      <div></div>
3130
3131
3132
3133    </div>
3134<pre class="api-signature no-pretty-print">
3135boolean hasWatcherTriggered (String watcherName)</pre>
3136
3137
3138
3139
3140  <p>Checks if a specific registered  <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> has triggered.
3141 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code>. If a UiWatcher runs and its
3142 <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html#checkForCondition()">checkForCondition()</a></code> call returned <code>true</code>, then
3143 the UiWatcher is considered triggered. This is helpful if a watcher is detecting errors
3144 from ANR or crash dialogs and the test needs to know if a UiWatcher has been triggered.</p>
3145
3146    <table class="responsive">
3147      <tr><th colspan=2>Returns</th></tr>
3148      <tr>
3149        <td><code>boolean</code></td>
3150        <td width="100%">true if triggered else false</td>
3151      </tr>
3152    </table>
3153
3154</div>
3155
3156
3157<A NAME="isNaturalOrientation()"></A>
3158
3159<div class="api apilevel-">
3160    <h3 class="api-name">isNaturalOrientation</h3>
3161    <div class="api-level">
3162      <div></div>
3163
3164
3165
3166    </div>
3167<pre class="api-signature no-pretty-print">
3168boolean isNaturalOrientation ()</pre>
3169
3170
3171
3172
3173  <p>Check if the device is in its natural orientation. This is determined by checking if the
3174 orientation is at 0 or 180 degrees.</p>
3175
3176    <table class="responsive">
3177      <tr><th colspan=2>Returns</th></tr>
3178      <tr>
3179        <td><code>boolean</code></td>
3180        <td width="100%">true if it is in natural orientation</td>
3181      </tr>
3182    </table>
3183
3184</div>
3185
3186
3187<A NAME="isScreenOn()"></A>
3188
3189<div class="api apilevel-">
3190    <h3 class="api-name">isScreenOn</h3>
3191    <div class="api-level">
3192      <div></div>
3193
3194
3195
3196    </div>
3197<pre class="api-signature no-pretty-print">
3198boolean isScreenOn ()</pre>
3199
3200
3201
3202
3203  <p>Checks the power manager if the screen is ON.</p>
3204
3205    <table class="responsive">
3206      <tr><th colspan=2>Returns</th></tr>
3207      <tr>
3208        <td><code>boolean</code></td>
3209        <td width="100%">true if the screen is ON else false</td>
3210      </tr>
3211    </table>
3212      <table class="responsive">
3213      <tr><th colspan=2>Throws</th></tr>
3214        <tr>
3215          <td><code></code></td>
3216          <td width="100%">RemoteException</td>
3217        </tr>
3218        <tr>
3219          <td><code>RemoteException</code></td>
3220          <td width="100%"></td>
3221        </tr>
3222      </table>
3223
3224
3225</div>
3226
3227
3228<A NAME="openNotification()"></A>
3229
3230<div class="api apilevel-">
3231    <h3 class="api-name">openNotification</h3>
3232    <div class="api-level">
3233      <div></div>
3234
3235
3236
3237    </div>
3238<pre class="api-signature no-pretty-print">
3239boolean openNotification ()</pre>
3240
3241
3242
3243
3244  <p>Opens the notification shade.</p>
3245
3246    <table class="responsive">
3247      <tr><th colspan=2>Returns</th></tr>
3248      <tr>
3249        <td><code>boolean</code></td>
3250        <td width="100%">true if successful, else return false</td>
3251      </tr>
3252    </table>
3253
3254</div>
3255
3256
3257<A NAME="openQuickSettings()"></A>
3258
3259<div class="api apilevel-">
3260    <h3 class="api-name">openQuickSettings</h3>
3261    <div class="api-level">
3262      <div></div>
3263
3264
3265
3266    </div>
3267<pre class="api-signature no-pretty-print">
3268boolean openQuickSettings ()</pre>
3269
3270
3271
3272
3273  <p>Opens the Quick Settings shade.</p>
3274
3275    <table class="responsive">
3276      <tr><th colspan=2>Returns</th></tr>
3277      <tr>
3278        <td><code>boolean</code></td>
3279        <td width="100%">true if successful, else return false</td>
3280      </tr>
3281    </table>
3282
3283</div>
3284
3285
3286<A NAME="performActionAndWait(java.lang.Runnable, android.support.test.uiautomator.EventCondition<R>, long)"></A>
3287
3288<div class="api apilevel-">
3289    <h3 class="api-name">performActionAndWait</h3>
3290    <div class="api-level">
3291      <div></div>
3292
3293
3294
3295    </div>
3296<pre class="api-signature no-pretty-print">
3297R performActionAndWait (Runnable action,
3298                <a href="/reference/android/support/test/uiautomator/EventCondition.html">EventCondition</a>&lt;R&gt; condition,
3299                long timeout)</pre>
3300
3301
3302
3303
3304  <p>Performs the provided <code>action</code> and waits for the <code>condition</code> to be met.</p>
3305    <table class="responsive">
3306    <tr><th colspan=2>Parameters</th></tr>
3307      <tr>
3308        <td><code>action</code></td>
3309        <td width="100%">
3310          <code>Runnable</code>:
3311          The <code><a href="/reference/java/lang/Runnable.html">Runnable</a></code> action to perform.</td>
3312      </tr>
3313      <tr>
3314        <td><code>condition</code></td>
3315        <td width="100%">
3316          <code>EventCondition</code>:
3317          The <code><a href="/reference/android/support/test/uiautomator/EventCondition.html">EventCondition</a></code> to evaluate.</td>
3318      </tr>
3319      <tr>
3320        <td><code>timeout</code></td>
3321        <td width="100%">
3322          <code>long</code>:
3323          Maximum amount of time to wait in milliseconds.</td>
3324      </tr>
3325    </table>
3326    <table class="responsive">
3327      <tr><th colspan=2>Returns</th></tr>
3328      <tr>
3329        <td><code>R</code></td>
3330        <td width="100%">The final result returned by the condition.
3331</td>
3332      </tr>
3333    </table>
3334
3335</div>
3336
3337
3338<A NAME="pressBack()"></A>
3339
3340<div class="api apilevel-">
3341    <h3 class="api-name">pressBack</h3>
3342    <div class="api-level">
3343      <div></div>
3344
3345
3346
3347    </div>
3348<pre class="api-signature no-pretty-print">
3349boolean pressBack ()</pre>
3350
3351
3352
3353
3354  <p>Simulates a short press on the BACK button.</p>
3355
3356    <table class="responsive">
3357      <tr><th colspan=2>Returns</th></tr>
3358      <tr>
3359        <td><code>boolean</code></td>
3360        <td width="100%">true if successful, else return false</td>
3361      </tr>
3362    </table>
3363
3364</div>
3365
3366
3367<A NAME="pressDPadCenter()"></A>
3368
3369<div class="api apilevel-">
3370    <h3 class="api-name">pressDPadCenter</h3>
3371    <div class="api-level">
3372      <div></div>
3373
3374
3375
3376    </div>
3377<pre class="api-signature no-pretty-print">
3378boolean pressDPadCenter ()</pre>
3379
3380
3381
3382
3383  <p>Simulates a short press on the CENTER button.</p>
3384
3385    <table class="responsive">
3386      <tr><th colspan=2>Returns</th></tr>
3387      <tr>
3388        <td><code>boolean</code></td>
3389        <td width="100%">true if successful, else return false</td>
3390      </tr>
3391    </table>
3392
3393</div>
3394
3395
3396<A NAME="pressDPadDown()"></A>
3397
3398<div class="api apilevel-">
3399    <h3 class="api-name">pressDPadDown</h3>
3400    <div class="api-level">
3401      <div></div>
3402
3403
3404
3405    </div>
3406<pre class="api-signature no-pretty-print">
3407boolean pressDPadDown ()</pre>
3408
3409
3410
3411
3412  <p>Simulates a short press on the DOWN button.</p>
3413
3414    <table class="responsive">
3415      <tr><th colspan=2>Returns</th></tr>
3416      <tr>
3417        <td><code>boolean</code></td>
3418        <td width="100%">true if successful, else return false</td>
3419      </tr>
3420    </table>
3421
3422</div>
3423
3424
3425<A NAME="pressDPadLeft()"></A>
3426
3427<div class="api apilevel-">
3428    <h3 class="api-name">pressDPadLeft</h3>
3429    <div class="api-level">
3430      <div></div>
3431
3432
3433
3434    </div>
3435<pre class="api-signature no-pretty-print">
3436boolean pressDPadLeft ()</pre>
3437
3438
3439
3440
3441  <p>Simulates a short press on the LEFT button.</p>
3442
3443    <table class="responsive">
3444      <tr><th colspan=2>Returns</th></tr>
3445      <tr>
3446        <td><code>boolean</code></td>
3447        <td width="100%">true if successful, else return false</td>
3448      </tr>
3449    </table>
3450
3451</div>
3452
3453
3454<A NAME="pressDPadRight()"></A>
3455
3456<div class="api apilevel-">
3457    <h3 class="api-name">pressDPadRight</h3>
3458    <div class="api-level">
3459      <div></div>
3460
3461
3462
3463    </div>
3464<pre class="api-signature no-pretty-print">
3465boolean pressDPadRight ()</pre>
3466
3467
3468
3469
3470  <p>Simulates a short press on the RIGHT button.</p>
3471
3472    <table class="responsive">
3473      <tr><th colspan=2>Returns</th></tr>
3474      <tr>
3475        <td><code>boolean</code></td>
3476        <td width="100%">true if successful, else return false</td>
3477      </tr>
3478    </table>
3479
3480</div>
3481
3482
3483<A NAME="pressDPadUp()"></A>
3484
3485<div class="api apilevel-">
3486    <h3 class="api-name">pressDPadUp</h3>
3487    <div class="api-level">
3488      <div></div>
3489
3490
3491
3492    </div>
3493<pre class="api-signature no-pretty-print">
3494boolean pressDPadUp ()</pre>
3495
3496
3497
3498
3499  <p>Simulates a short press on the UP button.</p>
3500
3501    <table class="responsive">
3502      <tr><th colspan=2>Returns</th></tr>
3503      <tr>
3504        <td><code>boolean</code></td>
3505        <td width="100%">true if successful, else return false</td>
3506      </tr>
3507    </table>
3508
3509</div>
3510
3511
3512<A NAME="pressDelete()"></A>
3513
3514<div class="api apilevel-">
3515    <h3 class="api-name">pressDelete</h3>
3516    <div class="api-level">
3517      <div></div>
3518
3519
3520
3521    </div>
3522<pre class="api-signature no-pretty-print">
3523boolean pressDelete ()</pre>
3524
3525
3526
3527
3528  <p>Simulates a short press on the DELETE key.</p>
3529
3530    <table class="responsive">
3531      <tr><th colspan=2>Returns</th></tr>
3532      <tr>
3533        <td><code>boolean</code></td>
3534        <td width="100%">true if successful, else return false</td>
3535      </tr>
3536    </table>
3537
3538</div>
3539
3540
3541<A NAME="pressEnter()"></A>
3542
3543<div class="api apilevel-">
3544    <h3 class="api-name">pressEnter</h3>
3545    <div class="api-level">
3546      <div></div>
3547
3548
3549
3550    </div>
3551<pre class="api-signature no-pretty-print">
3552boolean pressEnter ()</pre>
3553
3554
3555
3556
3557  <p>Simulates a short press on the ENTER key.</p>
3558
3559    <table class="responsive">
3560      <tr><th colspan=2>Returns</th></tr>
3561      <tr>
3562        <td><code>boolean</code></td>
3563        <td width="100%">true if successful, else return false</td>
3564      </tr>
3565    </table>
3566
3567</div>
3568
3569
3570<A NAME="pressHome()"></A>
3571
3572<div class="api apilevel-">
3573    <h3 class="api-name">pressHome</h3>
3574    <div class="api-level">
3575      <div></div>
3576
3577
3578
3579    </div>
3580<pre class="api-signature no-pretty-print">
3581boolean pressHome ()</pre>
3582
3583
3584
3585
3586  <p>Simulates a short press on the HOME button.</p>
3587
3588    <table class="responsive">
3589      <tr><th colspan=2>Returns</th></tr>
3590      <tr>
3591        <td><code>boolean</code></td>
3592        <td width="100%">true if successful, else return false</td>
3593      </tr>
3594    </table>
3595
3596</div>
3597
3598
3599<A NAME="pressKeyCode(int)"></A>
3600
3601<div class="api apilevel-">
3602    <h3 class="api-name">pressKeyCode</h3>
3603    <div class="api-level">
3604      <div></div>
3605
3606
3607
3608    </div>
3609<pre class="api-signature no-pretty-print">
3610boolean pressKeyCode (int keyCode)</pre>
3611
3612
3613
3614
3615  <p>Simulates a short press using a key code.
3616
3617 See <code><a href="/reference/android/view/KeyEvent.html">KeyEvent</a></code></p>
3618
3619    <table class="responsive">
3620    <tr><th colspan=2>Parameters</th></tr>
3621      <tr>
3622        <td><code>keyCode</code></td>
3623        <td width="100%">
3624          <code>int</code>
3625          <!-- no parameter comment --></td>
3626      </tr>
3627    </table>
3628    <table class="responsive">
3629      <tr><th colspan=2>Returns</th></tr>
3630      <tr>
3631        <td><code>boolean</code></td>
3632        <td width="100%">true if successful, else return false</td>
3633      </tr>
3634    </table>
3635
3636</div>
3637
3638
3639<A NAME="pressKeyCode(int, int)"></A>
3640
3641<div class="api apilevel-">
3642    <h3 class="api-name">pressKeyCode</h3>
3643    <div class="api-level">
3644      <div></div>
3645
3646
3647
3648    </div>
3649<pre class="api-signature no-pretty-print">
3650boolean pressKeyCode (int keyCode,
3651                int metaState)</pre>
3652
3653
3654
3655
3656  <p>Simulates a short press using a key code.
3657
3658 See <code><a href="/reference/android/view/KeyEvent.html">KeyEvent</a></code>.</p>
3659
3660    <table class="responsive">
3661    <tr><th colspan=2>Parameters</th></tr>
3662      <tr>
3663        <td><code>keyCode</code></td>
3664        <td width="100%">
3665          <code>int</code>:
3666          the key code of the event.</td>
3667      </tr>
3668      <tr>
3669        <td><code>metaState</code></td>
3670        <td width="100%">
3671          <code>int</code>:
3672          an integer in which each bit set to 1 represents a pressed meta key</td>
3673      </tr>
3674    </table>
3675    <table class="responsive">
3676      <tr><th colspan=2>Returns</th></tr>
3677      <tr>
3678        <td><code>boolean</code></td>
3679        <td width="100%">true if successful, else return false</td>
3680      </tr>
3681    </table>
3682
3683</div>
3684
3685
3686<A NAME="pressMenu()"></A>
3687
3688<div class="api apilevel-">
3689    <h3 class="api-name">pressMenu</h3>
3690    <div class="api-level">
3691      <div></div>
3692
3693
3694
3695    </div>
3696<pre class="api-signature no-pretty-print">
3697boolean pressMenu ()</pre>
3698
3699
3700
3701
3702  <p>Simulates a short press on the MENU button.</p>
3703
3704    <table class="responsive">
3705      <tr><th colspan=2>Returns</th></tr>
3706      <tr>
3707        <td><code>boolean</code></td>
3708        <td width="100%">true if successful, else return false</td>
3709      </tr>
3710    </table>
3711
3712</div>
3713
3714
3715<A NAME="pressRecentApps()"></A>
3716
3717<div class="api apilevel-">
3718    <h3 class="api-name">pressRecentApps</h3>
3719    <div class="api-level">
3720      <div></div>
3721
3722
3723
3724    </div>
3725<pre class="api-signature no-pretty-print">
3726boolean pressRecentApps ()</pre>
3727
3728
3729
3730
3731  <p>Simulates a short press on the Recent Apps button.</p>
3732
3733    <table class="responsive">
3734      <tr><th colspan=2>Returns</th></tr>
3735      <tr>
3736        <td><code>boolean</code></td>
3737        <td width="100%">true if successful, else return false</td>
3738      </tr>
3739    </table>
3740      <table class="responsive">
3741      <tr><th colspan=2>Throws</th></tr>
3742        <tr>
3743          <td><code></code></td>
3744          <td width="100%">RemoteException</td>
3745        </tr>
3746        <tr>
3747          <td><code>RemoteException</code></td>
3748          <td width="100%"></td>
3749        </tr>
3750      </table>
3751
3752
3753</div>
3754
3755
3756<A NAME="pressSearch()"></A>
3757
3758<div class="api apilevel-">
3759    <h3 class="api-name">pressSearch</h3>
3760    <div class="api-level">
3761      <div></div>
3762
3763
3764
3765    </div>
3766<pre class="api-signature no-pretty-print">
3767boolean pressSearch ()</pre>
3768
3769
3770
3771
3772  <p>Simulates a short press on the SEARCH button.</p>
3773
3774    <table class="responsive">
3775      <tr><th colspan=2>Returns</th></tr>
3776      <tr>
3777        <td><code>boolean</code></td>
3778        <td width="100%">true if successful, else return false</td>
3779      </tr>
3780    </table>
3781
3782</div>
3783
3784
3785<A NAME="registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)"></A>
3786
3787<div class="api apilevel-">
3788    <h3 class="api-name">registerWatcher</h3>
3789    <div class="api-level">
3790      <div></div>
3791
3792
3793
3794    </div>
3795<pre class="api-signature no-pretty-print">
3796void registerWatcher (String name,
3797                <a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a> watcher)</pre>
3798
3799
3800
3801
3802  <p>Registers a <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> to run automatically when the testing framework is unable to
3803 find a match using a <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code>. See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#runWatchers()">runWatchers()</a></code></p>
3804
3805    <table class="responsive">
3806    <tr><th colspan=2>Parameters</th></tr>
3807      <tr>
3808        <td><code>name</code></td>
3809        <td width="100%">
3810          <code>String</code>:
3811          to register the UiWatcher</td>
3812      </tr>
3813      <tr>
3814        <td><code>watcher</code></td>
3815        <td width="100%">
3816          <code>UiWatcher</code>:
3817          <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code></td>
3818      </tr>
3819    </table>
3820
3821</div>
3822
3823
3824<A NAME="removeWatcher(java.lang.String)"></A>
3825
3826<div class="api apilevel-">
3827    <h3 class="api-name">removeWatcher</h3>
3828    <div class="api-level">
3829      <div></div>
3830
3831
3832
3833    </div>
3834<pre class="api-signature no-pretty-print">
3835void removeWatcher (String name)</pre>
3836
3837
3838
3839
3840  <p>Removes a previously registered <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code>.
3841
3842 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p>
3843
3844    <table class="responsive">
3845    <tr><th colspan=2>Parameters</th></tr>
3846      <tr>
3847        <td><code>name</code></td>
3848        <td width="100%">
3849          <code>String</code>:
3850          used to register the UiWatcher</td>
3851      </tr>
3852    </table>
3853
3854</div>
3855
3856
3857<A NAME="resetWatcherTriggers()"></A>
3858
3859<div class="api apilevel-">
3860    <h3 class="api-name">resetWatcherTriggers</h3>
3861    <div class="api-level">
3862      <div></div>
3863
3864
3865
3866    </div>
3867<pre class="api-signature no-pretty-print">
3868void resetWatcherTriggers ()</pre>
3869
3870
3871
3872
3873  <p>Resets a <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></code> that has been triggered.
3874 If a UiWatcher runs and its <code><a href="/reference/android/support/test/uiautomator/UiWatcher.html#checkForCondition()">checkForCondition()</a></code> call
3875 returned <code>true</code>, then the UiWatcher is considered triggered.
3876 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p>
3877
3878
3879</div>
3880
3881
3882<A NAME="runWatchers()"></A>
3883
3884<div class="api apilevel-">
3885    <h3 class="api-name">runWatchers</h3>
3886    <div class="api-level">
3887      <div></div>
3888
3889
3890
3891    </div>
3892<pre class="api-signature no-pretty-print">
3893void runWatchers ()</pre>
3894
3895
3896
3897
3898  <p>This method forces all registered watchers to run.
3899 See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p>
3900
3901
3902</div>
3903
3904
3905<A NAME="setCompressedLayoutHeirarchy(boolean)"></A>
3906
3907<div class="api apilevel-">
3908    <h3 class="api-name">setCompressedLayoutHeirarchy</h3>
3909    <div class="api-level">
3910      <div></div>
3911
3912
3913
3914    </div>
3915<pre class="api-signature no-pretty-print">
3916void setCompressedLayoutHeirarchy (boolean compressed)</pre>
3917
3918
3919
3920
3921  <p>Enables or disables layout hierarchy compression.
3922
3923 If compression is enabled, the layout hierarchy derived from the Acessibility
3924 framework will only contain nodes that are important for uiautomator
3925 testing. Any unnecessary surrounding layout nodes that make viewing
3926 and searching the hierarchy inefficient are removed.</p>
3927
3928    <table class="responsive">
3929    <tr><th colspan=2>Parameters</th></tr>
3930      <tr>
3931        <td><code>compressed</code></td>
3932        <td width="100%">
3933          <code>boolean</code>:
3934          true to enable compression; else, false to disable</td>
3935      </tr>
3936    </table>
3937
3938</div>
3939
3940
3941<A NAME="setOrientationLeft()"></A>
3942
3943<div class="api apilevel-">
3944    <h3 class="api-name">setOrientationLeft</h3>
3945    <div class="api-level">
3946      <div></div>
3947
3948
3949
3950    </div>
3951<pre class="api-signature no-pretty-print">
3952void setOrientationLeft ()</pre>
3953
3954
3955
3956
3957  <p>Simulates orienting the device to the left and also freezes rotation
3958 by disabling the sensors.
3959
3960 If you want to un-freeze the rotation and re-enable the sensors
3961 see <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#unfreezeRotation()">unfreezeRotation()</a></code>.</p>
3962
3963      <table class="responsive">
3964      <tr><th colspan=2>Throws</th></tr>
3965        <tr>
3966          <td><code></code></td>
3967          <td width="100%">RemoteException</td>
3968        </tr>
3969        <tr>
3970          <td><code>RemoteException</code></td>
3971          <td width="100%"></td>
3972        </tr>
3973      </table>
3974
3975
3976</div>
3977
3978
3979<A NAME="setOrientationNatural()"></A>
3980
3981<div class="api apilevel-">
3982    <h3 class="api-name">setOrientationNatural</h3>
3983    <div class="api-level">
3984      <div></div>
3985
3986
3987
3988    </div>
3989<pre class="api-signature no-pretty-print">
3990void setOrientationNatural ()</pre>
3991
3992
3993
3994
3995  <p>Simulates orienting the device into its natural orientation and also freezes rotation
3996 by disabling the sensors.
3997
3998 If you want to un-freeze the rotation and re-enable the sensors
3999 see <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#unfreezeRotation()">unfreezeRotation()</a></code>.</p>
4000
4001      <table class="responsive">
4002      <tr><th colspan=2>Throws</th></tr>
4003        <tr>
4004          <td><code></code></td>
4005          <td width="100%">RemoteException</td>
4006        </tr>
4007        <tr>
4008          <td><code>RemoteException</code></td>
4009          <td width="100%"></td>
4010        </tr>
4011      </table>
4012
4013
4014</div>
4015
4016
4017<A NAME="setOrientationRight()"></A>
4018
4019<div class="api apilevel-">
4020    <h3 class="api-name">setOrientationRight</h3>
4021    <div class="api-level">
4022      <div></div>
4023
4024
4025
4026    </div>
4027<pre class="api-signature no-pretty-print">
4028void setOrientationRight ()</pre>
4029
4030
4031
4032
4033  <p>Simulates orienting the device to the right and also freezes rotation
4034 by disabling the sensors.
4035
4036 If you want to un-freeze the rotation and re-enable the sensors
4037 see <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#unfreezeRotation()">unfreezeRotation()</a></code>.</p>
4038
4039      <table class="responsive">
4040      <tr><th colspan=2>Throws</th></tr>
4041        <tr>
4042          <td><code></code></td>
4043          <td width="100%">RemoteException</td>
4044        </tr>
4045        <tr>
4046          <td><code>RemoteException</code></td>
4047          <td width="100%"></td>
4048        </tr>
4049      </table>
4050
4051
4052</div>
4053
4054
4055<A NAME="sleep()"></A>
4056
4057<div class="api apilevel-">
4058    <h3 class="api-name">sleep</h3>
4059    <div class="api-level">
4060      <div></div>
4061
4062
4063
4064    </div>
4065<pre class="api-signature no-pretty-print">
4066void sleep ()</pre>
4067
4068
4069
4070
4071  <p>This method simply presses the power button if the screen is ON else
4072 it does nothing if the screen is already OFF.</p>
4073
4074      <table class="responsive">
4075      <tr><th colspan=2>Throws</th></tr>
4076        <tr>
4077          <td><code></code></td>
4078          <td width="100%">RemoteException</td>
4079        </tr>
4080        <tr>
4081          <td><code>RemoteException</code></td>
4082          <td width="100%"></td>
4083        </tr>
4084      </table>
4085
4086
4087</div>
4088
4089
4090<A NAME="swipe(int, int, int, int, int)"></A>
4091
4092<div class="api apilevel-">
4093    <h3 class="api-name">swipe</h3>
4094    <div class="api-level">
4095      <div></div>
4096
4097
4098
4099    </div>
4100<pre class="api-signature no-pretty-print">
4101boolean swipe (int startX,
4102                int startY,
4103                int endX,
4104                int endY,
4105                int steps)</pre>
4106
4107
4108
4109
4110  <p>Performs a swipe from one coordinate to another using the number of steps
4111 to determine smoothness and speed. Each step execution is throttled to 5ms
4112 per step. So for a 100 steps, the swipe will take about 1/2 second to complete.</p>
4113
4114    <table class="responsive">
4115    <tr><th colspan=2>Parameters</th></tr>
4116      <tr>
4117        <td><code>steps</code></td>
4118        <td width="100%">
4119          <code>int</code>:
4120          is the number of move steps sent to the system</td>
4121      </tr>
4122    </table>
4123    <table class="responsive">
4124      <tr><th colspan=2>Returns</th></tr>
4125      <tr>
4126        <td><code>boolean</code></td>
4127        <td width="100%">false if the operation fails or the coordinates are invalid</td>
4128      </tr>
4129    </table>
4130
4131</div>
4132
4133
4134<A NAME="swipe(android.graphics.Point[], int)"></A>
4135
4136<div class="api apilevel-">
4137    <h3 class="api-name">swipe</h3>
4138    <div class="api-level">
4139      <div></div>
4140
4141
4142
4143    </div>
4144<pre class="api-signature no-pretty-print">
4145boolean swipe (Point[] segments,
4146                int segmentSteps)</pre>
4147
4148
4149
4150
4151  <p>Performs a swipe between points in the Point array. Each step execution is throttled
4152 to 5ms per step. So for a 100 steps, the swipe will take about 1/2 second to complete</p>
4153
4154    <table class="responsive">
4155    <tr><th colspan=2>Parameters</th></tr>
4156      <tr>
4157        <td><code>segments</code></td>
4158        <td width="100%">
4159          <code>Point</code>:
4160          is Point array containing at least one Point object</td>
4161      </tr>
4162      <tr>
4163        <td><code>segmentSteps</code></td>
4164        <td width="100%">
4165          <code>int</code>:
4166          steps to inject between two Points</td>
4167      </tr>
4168    </table>
4169    <table class="responsive">
4170      <tr><th colspan=2>Returns</th></tr>
4171      <tr>
4172        <td><code>boolean</code></td>
4173        <td width="100%">true on success</td>
4174      </tr>
4175    </table>
4176
4177</div>
4178
4179
4180<A NAME="takeScreenshot(java.io.File, float, int)"></A>
4181
4182<div class="api apilevel-">
4183    <h3 class="api-name">takeScreenshot</h3>
4184    <div class="api-level">
4185      <div></div>
4186
4187
4188
4189    </div>
4190<pre class="api-signature no-pretty-print">
4191boolean takeScreenshot (File storePath,
4192                float scale,
4193                int quality)</pre>
4194
4195
4196
4197
4198  <p>Take a screenshot of current window and store it as PNG
4199
4200 The screenshot is adjusted per screen rotation</p>
4201
4202    <table class="responsive">
4203    <tr><th colspan=2>Parameters</th></tr>
4204      <tr>
4205        <td><code>storePath</code></td>
4206        <td width="100%">
4207          <code>File</code>:
4208          where the PNG should be written to</td>
4209      </tr>
4210      <tr>
4211        <td><code>scale</code></td>
4212        <td width="100%">
4213          <code>float</code>:
4214          scale the screenshot down if needed; 1.0f for original size</td>
4215      </tr>
4216      <tr>
4217        <td><code>quality</code></td>
4218        <td width="100%">
4219          <code>int</code>:
4220          quality of the PNG compression; range: 0-100</td>
4221      </tr>
4222    </table>
4223    <table class="responsive">
4224      <tr><th colspan=2>Returns</th></tr>
4225      <tr>
4226        <td><code>boolean</code></td>
4227        <td width="100%">true if screen shot is created successfully, false otherwise</td>
4228      </tr>
4229    </table>
4230
4231</div>
4232
4233
4234<A NAME="takeScreenshot(java.io.File)"></A>
4235
4236<div class="api apilevel-">
4237    <h3 class="api-name">takeScreenshot</h3>
4238    <div class="api-level">
4239      <div></div>
4240
4241
4242
4243    </div>
4244<pre class="api-signature no-pretty-print">
4245boolean takeScreenshot (File storePath)</pre>
4246
4247
4248
4249
4250  <p>Take a screenshot of current window and store it as PNG
4251
4252 Default scale of 1.0f (original size) and 90% quality is used
4253 The screenshot is adjusted per screen rotation</p>
4254
4255    <table class="responsive">
4256    <tr><th colspan=2>Parameters</th></tr>
4257      <tr>
4258        <td><code>storePath</code></td>
4259        <td width="100%">
4260          <code>File</code>:
4261          where the PNG should be written to</td>
4262      </tr>
4263    </table>
4264    <table class="responsive">
4265      <tr><th colspan=2>Returns</th></tr>
4266      <tr>
4267        <td><code>boolean</code></td>
4268        <td width="100%">true if screen shot is created successfully, false otherwise</td>
4269      </tr>
4270    </table>
4271
4272</div>
4273
4274
4275<A NAME="unfreezeRotation()"></A>
4276
4277<div class="api apilevel-">
4278    <h3 class="api-name">unfreezeRotation</h3>
4279    <div class="api-level">
4280      <div></div>
4281
4282
4283
4284    </div>
4285<pre class="api-signature no-pretty-print">
4286void unfreezeRotation ()</pre>
4287
4288
4289
4290
4291  <p>Re-enables the sensors and un-freezes the device rotation allowing its contents
4292 to rotate with the device physical rotation. During a test execution, it is best to
4293 keep the device frozen in a specific orientation until the test case execution has completed.</p>
4294      <table class="responsive">
4295      <tr><th colspan=2>Throws</th></tr>
4296        <tr>
4297          <td><code>RemoteException</code></td>
4298          <td width="100%"></td>
4299        </tr>
4300      </table>
4301
4302
4303</div>
4304
4305
4306<A NAME="wait(android.support.test.uiautomator.SearchCondition<R>, long)"></A>
4307
4308<div class="api apilevel-">
4309    <h3 class="api-name">wait</h3>
4310    <div class="api-level">
4311      <div></div>
4312
4313
4314
4315    </div>
4316<pre class="api-signature no-pretty-print">
4317R wait (<a href="/reference/android/support/test/uiautomator/SearchCondition.html">SearchCondition</a>&lt;R&gt; condition,
4318                long timeout)</pre>
4319
4320
4321
4322
4323  <p>Waits for given the <code>condition</code> to be met.</p>
4324    <table class="responsive">
4325    <tr><th colspan=2>Parameters</th></tr>
4326      <tr>
4327        <td><code>condition</code></td>
4328        <td width="100%">
4329          <code>SearchCondition</code>:
4330          The <code><a href="/reference/android/support/test/uiautomator/SearchCondition.html">SearchCondition</a></code> to evaluate.</td>
4331      </tr>
4332      <tr>
4333        <td><code>timeout</code></td>
4334        <td width="100%">
4335          <code>long</code>:
4336          Maximum amount of time to wait in milliseconds.</td>
4337      </tr>
4338    </table>
4339    <table class="responsive">
4340      <tr><th colspan=2>Returns</th></tr>
4341      <tr>
4342        <td><code>R</code></td>
4343        <td width="100%">The final result returned by the condition.
4344</td>
4345      </tr>
4346    </table>
4347
4348</div>
4349
4350
4351<A NAME="waitForIdle(long)"></A>
4352
4353<div class="api apilevel-">
4354    <h3 class="api-name">waitForIdle</h3>
4355    <div class="api-level">
4356      <div></div>
4357
4358
4359
4360    </div>
4361<pre class="api-signature no-pretty-print">
4362void waitForIdle (long timeout)</pre>
4363
4364
4365
4366
4367  <p>Waits for the current application to idle.</p>
4368
4369    <table class="responsive">
4370    <tr><th colspan=2>Parameters</th></tr>
4371      <tr>
4372        <td><code>timeout</code></td>
4373        <td width="100%">
4374          <code>long</code>:
4375          in milliseconds</td>
4376      </tr>
4377    </table>
4378
4379</div>
4380
4381
4382<A NAME="waitForIdle()"></A>
4383
4384<div class="api apilevel-">
4385    <h3 class="api-name">waitForIdle</h3>
4386    <div class="api-level">
4387      <div></div>
4388
4389
4390
4391    </div>
4392<pre class="api-signature no-pretty-print">
4393void waitForIdle ()</pre>
4394
4395
4396
4397
4398  <p>Waits for the current application to idle.
4399 Default wait timeout is 10 seconds</p>
4400
4401
4402</div>
4403
4404
4405<A NAME="waitForWindowUpdate(java.lang.String, long)"></A>
4406
4407<div class="api apilevel-">
4408    <h3 class="api-name">waitForWindowUpdate</h3>
4409    <div class="api-level">
4410      <div></div>
4411
4412
4413
4414    </div>
4415<pre class="api-signature no-pretty-print">
4416boolean waitForWindowUpdate (String packageName,
4417                long timeout)</pre>
4418
4419
4420
4421
4422  <p>Waits for a window content update event to occur.
4423
4424 If a package name for the window is specified, but the current window
4425 does not have the same package name, the function returns immediately.</p>
4426
4427    <table class="responsive">
4428    <tr><th colspan=2>Parameters</th></tr>
4429      <tr>
4430        <td><code>packageName</code></td>
4431        <td width="100%">
4432          <code>String</code>:
4433          the specified window package name (can be <code>null</code>).
4434        If <code>null</code>, a window update from any front-end window will end the wait</td>
4435      </tr>
4436      <tr>
4437        <td><code>timeout</code></td>
4438        <td width="100%">
4439          <code>long</code>:
4440          the timeout for the wait</td>
4441      </tr>
4442    </table>
4443    <table class="responsive">
4444      <tr><th colspan=2>Returns</th></tr>
4445      <tr>
4446        <td><code>boolean</code></td>
4447        <td width="100%">true if a window update occurred, false if timeout has elapsed or if the current
4448         window does not have the specified package name</td>
4449      </tr>
4450    </table>
4451
4452</div>
4453
4454
4455<A NAME="wakeUp()"></A>
4456
4457<div class="api apilevel-">
4458    <h3 class="api-name">wakeUp</h3>
4459    <div class="api-level">
4460      <div></div>
4461
4462
4463
4464    </div>
4465<pre class="api-signature no-pretty-print">
4466void wakeUp ()</pre>
4467
4468
4469
4470
4471  <p>This method simulates pressing the power button if the screen is OFF else
4472 it does nothing if the screen is already ON.
4473
4474 If the screen was OFF and it just got turned ON, this method will insert a 500ms delay
4475 to allow the device time to wake up and accept input.</p>
4476
4477      <table class="responsive">
4478      <tr><th colspan=2>Throws</th></tr>
4479        <tr>
4480          <td><code></code></td>
4481          <td width="100%">RemoteException</td>
4482        </tr>
4483        <tr>
4484          <td><code>RemoteException</code></td>
4485          <td width="100%"></td>
4486        </tr>
4487      </table>
4488
4489
4490</div>
4491
4492
4493
4494
4495
4496<!-- ========= METHOD DETAIL ======== -->
4497
4498
4499
4500<!-- ========= END OF CLASS DATA ========= -->
4501
4502</div><!-- end jd-content -->
4503
4504
4505
4506<div class="data-reference-resources-wrapper">
4507
4508  <ul data-reference-resources>
4509
4510
4511    <li><h2>Interfaces</h2>
4512      <ul>
4513          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/IAutomationSupport.html">IAutomationSupport</a></li>
4514          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></li>
4515      </ul>
4516    </li>
4517
4518    <li><h2>Classes</h2>
4519      <ul>
4520          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/By.html">By</a></li>
4521          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a></li>
4522          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Configurator.html">Configurator</a></li>
4523          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/EventCondition.html">EventCondition</a></li>
4524          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/SearchCondition.html">SearchCondition</a></li>
4525          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiAutomatorInstrumentationTestRunner.html">UiAutomatorInstrumentationTestRunner</a></li>
4526          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiAutomatorTestCase.html">UiAutomatorTestCase</a></li>
4527          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiCollection.html">UiCollection</a></li>
4528          <li class="selected api apilevel-"><a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></li>
4529          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject.html">UiObject</a></li>
4530          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a></li>
4531          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject2Condition.html">UiObject2Condition</a></li>
4532          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiScrollable.html">UiScrollable</a></li>
4533          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></li>
4534          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Until.html">Until</a></li>
4535      </ul>
4536    </li>
4537
4538    <li><h2>Enums</h2>
4539      <ul>
4540          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Direction.html">Direction</a></li>
4541      </ul>
4542    </li>
4543
4544    <li><h2>Exceptions</h2>
4545      <ul>
4546          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/StaleObjectException.html">StaleObjectException</a></li>
4547          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObjectNotFoundException.html">UiObjectNotFoundException</a></li>
4548      </ul>
4549    </li>
4550
4551  </ul>
4552
4553</div>
4554
4555
4556
4557</body>
4558</html>
4559