Home | History | Annotate | Download | only in uiautomator
      1 page.title=UiDevice
      2 parent.title=uiautomator
      3 parent.link=index.html
      4 @jd:body
      5 <style>
      6     h4.jd-details-title {background-color: #DEE8F1;}
      7 </style>
      8 <p>Provides access to state information about the device. You can
      9 also use this class to simulate user actions on the device, such as pressing
     10 the d-pad or pressing the Home and Menu buttons.</p>
     11 
     12 <h2>Summary</h2>
     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 <!-- ========== METHOD SUMMARY =========== -->
     41 <table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr>
     42 
     43 
     44 
     45 
     46     <tr class="api" >
     47         <td class="jd-typecol"><nobr>
     48 
     49 
     50 
     51 
     52 
     53             void</nobr>
     54         </td>
     55         <td class="jd-linkcol" width="100%"><nobr>
     56         <span class="sympad"><a href="#clearLastTraversedText()">clearLastTraversedText</a></span>()</nobr>
     57 
     58         <div class="jd-descrdiv">Clears the text from the last UI traversal event.</div>
     59 
     60   </td></tr>
     61 
     62 
     63 
     64     <tr class="api" >
     65         <td class="jd-typecol"><nobr>
     66 
     67 
     68 
     69 
     70 
     71             boolean</nobr>
     72         </td>
     73         <td class="jd-linkcol" width="100%"><nobr>
     74         <span class="sympad"><a href="#click(int, int)">click</a></span>(int x, int y)</nobr>
     75 
     76         <div class="jd-descrdiv">Perform a click at arbitrary coordinates specified by the user</div>
     77 
     78   </td></tr>
     79 
     80 
     81 
     82     <tr class="api" >
     83         <td class="jd-typecol"><nobr>
     84 
     85 
     86 
     87 
     88 
     89             boolean</nobr>
     90         </td>
     91         <td class="jd-linkcol" width="100%"><nobr>
     92         <span class="sympad"><a href="#drag(int, int, int, int, int)">drag</a></span>(int startX, int startY, int endX, int endY, int steps)</nobr>
     93 
     94         <div class="jd-descrdiv">Performs a swipe from one coordinate to another coordinate.</div>
     95 
     96   </td></tr>
     97 
     98 
     99 
    100     <tr class="api" >
    101         <td class="jd-typecol"><nobr>
    102 
    103 
    104 
    105 
    106 
    107             void</nobr>
    108         </td>
    109         <td class="jd-linkcol" width="100%"><nobr>
    110         <span class="sympad"><a href="#dumpWindowHierarchy(java.lang.String)">dumpWindowHierarchy</a></span>(String fileName)</nobr>
    111 
    112         <div class="jd-descrdiv">Helper method used for debugging to dump the current window's layout hierarchy.</div>
    113 
    114   </td></tr>
    115 
    116 
    117 
    118     <tr class="api" >
    119         <td class="jd-typecol"><nobr>
    120 
    121 
    122 
    123 
    124 
    125             void</nobr>
    126         </td>
    127         <td class="jd-linkcol" width="100%"><nobr>
    128         <span class="sympad"><a href="#freezeRotation()">freezeRotation</a></span>()</nobr>
    129 
    130         <div class="jd-descrdiv">Disables the sensors and freezes the device rotation at its
    131  current rotation state.</div>
    132 
    133   </td></tr>
    134 
    135 
    136 
    137     <tr class="api" >
    138         <td class="jd-typecol"><nobr>
    139 
    140 
    141 
    142 
    143 
    144             String</nobr>
    145         </td>
    146         <td class="jd-linkcol" width="100%"><nobr>
    147         <span class="sympad"><a href="#getCurrentActivityName()">getCurrentActivityName</a></span>()</nobr>
    148 
    149         <div class="jd-descrdiv"><em>
    150       This method is deprecated.
    151     The results returned should be considered unreliable</em></div>
    152 
    153   </td></tr>
    154 
    155 
    156 
    157     <tr class="api" >
    158         <td class="jd-typecol"><nobr>
    159 
    160 
    161 
    162 
    163 
    164             String</nobr>
    165         </td>
    166         <td class="jd-linkcol" width="100%"><nobr>
    167         <span class="sympad"><a href="#getCurrentPackageName()">getCurrentPackageName</a></span>()</nobr>
    168 
    169         <div class="jd-descrdiv">Retrieves the name of the last package to report accessibility events.</div>
    170 
    171   </td></tr>
    172 
    173 
    174 
    175     <tr class="api" >
    176         <td class="jd-typecol"><nobr>
    177 
    178 
    179 
    180 
    181 
    182             int</nobr>
    183         </td>
    184         <td class="jd-linkcol" width="100%"><nobr>
    185         <span class="sympad"><a href="#getDisplayHeight()">getDisplayHeight</a></span>()</nobr>
    186 
    187         <div class="jd-descrdiv">Gets the height of the display, in pixels.</div>
    188 
    189   </td></tr>
    190 
    191 
    192 
    193     <tr class="api" >
    194         <td class="jd-typecol"><nobr>
    195 
    196 
    197 
    198 
    199 
    200             int</nobr>
    201         </td>
    202         <td class="jd-linkcol" width="100%"><nobr>
    203         <span class="sympad"><a href="#getDisplayRotation()">getDisplayRotation</a></span>()</nobr>
    204 
    205         <div class="jd-descrdiv">Returns the current rotation of the display, as defined in <code><a href="../../../../../reference/android/view/Surface.html">Surface</a></code></div>
    206 
    207   </td></tr>
    208 
    209 
    210 
    211     <tr class="api" >
    212         <td class="jd-typecol"><nobr>
    213 
    214 
    215 
    216 
    217 
    218             Point</nobr>
    219         </td>
    220         <td class="jd-linkcol" width="100%"><nobr>
    221         <span class="sympad"><a href="#getDisplaySizeDp()">getDisplaySizeDp</a></span>()</nobr>
    222 
    223         <div class="jd-descrdiv">Returns the display size in dp (device-independent pixel)
    224 
    225  The returned display size is adjusted per screen rotation.</div>
    226 
    227   </td></tr>
    228 
    229 
    230 
    231     <tr class="api" >
    232         <td class="jd-typecol"><nobr>
    233 
    234 
    235 
    236 
    237 
    238             int</nobr>
    239         </td>
    240         <td class="jd-linkcol" width="100%"><nobr>
    241         <span class="sympad"><a href="#getDisplayWidth()">getDisplayWidth</a></span>()</nobr>
    242 
    243         <div class="jd-descrdiv">Gets the width of the display, in pixels.</div>
    244 
    245   </td></tr>
    246 
    247 
    248 
    249     <tr class="api" >
    250         <td class="jd-typecol"><nobr>
    251 
    252 
    253 
    254             static
    255 
    256             <a href="#">UiDevice</a></nobr>
    257         </td>
    258         <td class="jd-linkcol" width="100%"><nobr>
    259         <span class="sympad"><a href="#getInstance()">getInstance</a></span>()</nobr>
    260 
    261         <div class="jd-descrdiv">Retrieves a singleton instance of UiDevice</div>
    262 
    263   </td></tr>
    264 
    265 
    266 
    267     <tr class="api" >
    268         <td class="jd-typecol"><nobr>
    269 
    270 
    271 
    272 
    273 
    274             String</nobr>
    275         </td>
    276         <td class="jd-linkcol" width="100%"><nobr>
    277         <span class="sympad"><a href="#getLastTraversedText()">getLastTraversedText</a></span>()</nobr>
    278 
    279         <div class="jd-descrdiv">Retrieves the text from the last UI traversal event received.</div>
    280 
    281   </td></tr>
    282 
    283 
    284 
    285     <tr class="api" >
    286         <td class="jd-typecol"><nobr>
    287 
    288 
    289 
    290 
    291 
    292             String</nobr>
    293         </td>
    294         <td class="jd-linkcol" width="100%"><nobr>
    295         <span class="sympad"><a href="#getProductName()">getProductName</a></span>()</nobr>
    296 
    297         <div class="jd-descrdiv">Retrieves the product name of the device.</div>
    298 
    299   </td></tr>
    300 
    301 
    302 
    303     <tr class="api" >
    304         <td class="jd-typecol"><nobr>
    305 
    306 
    307 
    308 
    309 
    310             boolean</nobr>
    311         </td>
    312         <td class="jd-linkcol" width="100%"><nobr>
    313         <span class="sympad"><a href="#hasAnyWatcherTriggered()">hasAnyWatcherTriggered</a></span>()</nobr>
    314 
    315         <div class="jd-descrdiv">Checks if any registered <code><a href="UiWatcher.html">UiWatcher</a></code> have triggered.</div>
    316 
    317   </td></tr>
    318 
    319 
    320 
    321     <tr class="api" >
    322         <td class="jd-typecol"><nobr>
    323 
    324 
    325 
    326 
    327 
    328             boolean</nobr>
    329         </td>
    330         <td class="jd-linkcol" width="100%"><nobr>
    331         <span class="sympad"><a href="#hasWatcherTriggered(java.lang.String)">hasWatcherTriggered</a></span>(String watcherName)</nobr>
    332 
    333         <div class="jd-descrdiv">Checks if a specific registered  <code><a href="UiWatcher.html">UiWatcher</a></code> has triggered.</div>
    334 
    335   </td></tr>
    336 
    337 
    338 
    339     <tr class="api" >
    340         <td class="jd-typecol"><nobr>
    341 
    342 
    343 
    344 
    345 
    346             boolean</nobr>
    347         </td>
    348         <td class="jd-linkcol" width="100%"><nobr>
    349         <span class="sympad"><a href="#isNaturalOrientation()">isNaturalOrientation</a></span>()</nobr>
    350 
    351         <div class="jd-descrdiv">Check if the device is in its natural orientation.</div>
    352 
    353   </td></tr>
    354 
    355 
    356 
    357     <tr class="api" >
    358         <td class="jd-typecol"><nobr>
    359 
    360 
    361 
    362 
    363 
    364             boolean</nobr>
    365         </td>
    366         <td class="jd-linkcol" width="100%"><nobr>
    367         <span class="sympad"><a href="#isScreenOn()">isScreenOn</a></span>()</nobr>
    368 
    369         <div class="jd-descrdiv">Checks the power manager if the screen is ON.</div>
    370 
    371   </td></tr>
    372 
    373 
    374 
    375     <tr class="api" >
    376         <td class="jd-typecol"><nobr>
    377 
    378 
    379 
    380 
    381 
    382             boolean</nobr>
    383         </td>
    384         <td class="jd-linkcol" width="100%"><nobr>
    385         <span class="sympad"><a href="#openNotification()">openNotification</a></span>()</nobr>
    386 
    387         <div class="jd-descrdiv">Opens the notification shade.</div>
    388 
    389   </td></tr>
    390 
    391 
    392 
    393     <tr class="api" >
    394         <td class="jd-typecol"><nobr>
    395 
    396 
    397 
    398 
    399 
    400             boolean</nobr>
    401         </td>
    402         <td class="jd-linkcol" width="100%"><nobr>
    403         <span class="sympad"><a href="#openQuickSettings()">openQuickSettings</a></span>()</nobr>
    404 
    405         <div class="jd-descrdiv">Opens the Quick Settings shade.</div>
    406 
    407   </td></tr>
    408 
    409 
    410 
    411     <tr class="api" >
    412         <td class="jd-typecol"><nobr>
    413 
    414 
    415 
    416 
    417 
    418             boolean</nobr>
    419         </td>
    420         <td class="jd-linkcol" width="100%"><nobr>
    421         <span class="sympad"><a href="#pressBack()">pressBack</a></span>()</nobr>
    422 
    423         <div class="jd-descrdiv">Simulates a short press on the BACK button.</div>
    424 
    425   </td></tr>
    426 
    427 
    428 
    429     <tr class="api" >
    430         <td class="jd-typecol"><nobr>
    431 
    432 
    433 
    434 
    435 
    436             boolean</nobr>
    437         </td>
    438         <td class="jd-linkcol" width="100%"><nobr>
    439         <span class="sympad"><a href="#pressDPadCenter()">pressDPadCenter</a></span>()</nobr>
    440 
    441         <div class="jd-descrdiv">Simulates a short press on the CENTER button.</div>
    442 
    443   </td></tr>
    444 
    445 
    446 
    447     <tr class="api" >
    448         <td class="jd-typecol"><nobr>
    449 
    450 
    451 
    452 
    453 
    454             boolean</nobr>
    455         </td>
    456         <td class="jd-linkcol" width="100%"><nobr>
    457         <span class="sympad"><a href="#pressDPadDown()">pressDPadDown</a></span>()</nobr>
    458 
    459         <div class="jd-descrdiv">Simulates a short press on the DOWN button.</div>
    460 
    461   </td></tr>
    462 
    463 
    464 
    465     <tr class="api" >
    466         <td class="jd-typecol"><nobr>
    467 
    468 
    469 
    470 
    471 
    472             boolean</nobr>
    473         </td>
    474         <td class="jd-linkcol" width="100%"><nobr>
    475         <span class="sympad"><a href="#pressDPadLeft()">pressDPadLeft</a></span>()</nobr>
    476 
    477         <div class="jd-descrdiv">Simulates a short press on the LEFT button.</div>
    478 
    479   </td></tr>
    480 
    481 
    482 
    483     <tr class="api" >
    484         <td class="jd-typecol"><nobr>
    485 
    486 
    487 
    488 
    489 
    490             boolean</nobr>
    491         </td>
    492         <td class="jd-linkcol" width="100%"><nobr>
    493         <span class="sympad"><a href="#pressDPadRight()">pressDPadRight</a></span>()</nobr>
    494 
    495         <div class="jd-descrdiv">Simulates a short press on the RIGHT button.</div>
    496 
    497   </td></tr>
    498 
    499 
    500 
    501     <tr class="api" >
    502         <td class="jd-typecol"><nobr>
    503 
    504 
    505 
    506 
    507 
    508             boolean</nobr>
    509         </td>
    510         <td class="jd-linkcol" width="100%"><nobr>
    511         <span class="sympad"><a href="#pressDPadUp()">pressDPadUp</a></span>()</nobr>
    512 
    513         <div class="jd-descrdiv">Simulates a short press on the UP button.</div>
    514 
    515   </td></tr>
    516 
    517 
    518 
    519     <tr class="api" >
    520         <td class="jd-typecol"><nobr>
    521 
    522 
    523 
    524 
    525 
    526             boolean</nobr>
    527         </td>
    528         <td class="jd-linkcol" width="100%"><nobr>
    529         <span class="sympad"><a href="#pressDelete()">pressDelete</a></span>()</nobr>
    530 
    531         <div class="jd-descrdiv">Simulates a short press on the DELETE key.</div>
    532 
    533   </td></tr>
    534 
    535 
    536 
    537     <tr class="api" >
    538         <td class="jd-typecol"><nobr>
    539 
    540 
    541 
    542 
    543 
    544             boolean</nobr>
    545         </td>
    546         <td class="jd-linkcol" width="100%"><nobr>
    547         <span class="sympad"><a href="#pressEnter()">pressEnter</a></span>()</nobr>
    548 
    549         <div class="jd-descrdiv">Simulates a short press on the ENTER key.</div>
    550 
    551   </td></tr>
    552 
    553 
    554 
    555     <tr class="api" >
    556         <td class="jd-typecol"><nobr>
    557 
    558 
    559 
    560 
    561 
    562             boolean</nobr>
    563         </td>
    564         <td class="jd-linkcol" width="100%"><nobr>
    565         <span class="sympad"><a href="#pressHome()">pressHome</a></span>()</nobr>
    566 
    567         <div class="jd-descrdiv">Simulates a short press on the HOME button.</div>
    568 
    569   </td></tr>
    570 
    571 
    572 
    573     <tr class="api" >
    574         <td class="jd-typecol"><nobr>
    575 
    576 
    577 
    578 
    579 
    580             boolean</nobr>
    581         </td>
    582         <td class="jd-linkcol" width="100%"><nobr>
    583         <span class="sympad"><a href="#pressKeyCode(int, int)">pressKeyCode</a></span>(int keyCode, int metaState)</nobr>
    584 
    585         <div class="jd-descrdiv">Simulates a short press using a key code.</div>
    586 
    587   </td></tr>
    588 
    589 
    590 
    591     <tr class="api" >
    592         <td class="jd-typecol"><nobr>
    593 
    594 
    595 
    596 
    597 
    598             boolean</nobr>
    599         </td>
    600         <td class="jd-linkcol" width="100%"><nobr>
    601         <span class="sympad"><a href="#pressKeyCode(int)">pressKeyCode</a></span>(int keyCode)</nobr>
    602 
    603         <div class="jd-descrdiv">Simulates a short press using a key code.</div>
    604 
    605   </td></tr>
    606 
    607 
    608 
    609     <tr class="api" >
    610         <td class="jd-typecol"><nobr>
    611 
    612 
    613 
    614 
    615 
    616             boolean</nobr>
    617         </td>
    618         <td class="jd-linkcol" width="100%"><nobr>
    619         <span class="sympad"><a href="#pressMenu()">pressMenu</a></span>()</nobr>
    620 
    621         <div class="jd-descrdiv">Simulates a short press on the MENU button.</div>
    622 
    623   </td></tr>
    624 
    625 
    626 
    627     <tr class="api" >
    628         <td class="jd-typecol"><nobr>
    629 
    630 
    631 
    632 
    633 
    634             boolean</nobr>
    635         </td>
    636         <td class="jd-linkcol" width="100%"><nobr>
    637         <span class="sympad"><a href="#pressRecentApps()">pressRecentApps</a></span>()</nobr>
    638 
    639         <div class="jd-descrdiv">Simulates a short press on the Recent Apps button.</div>
    640 
    641   </td></tr>
    642 
    643 
    644 
    645     <tr class="api" >
    646         <td class="jd-typecol"><nobr>
    647 
    648 
    649 
    650 
    651 
    652             boolean</nobr>
    653         </td>
    654         <td class="jd-linkcol" width="100%"><nobr>
    655         <span class="sympad"><a href="#pressSearch()">pressSearch</a></span>()</nobr>
    656 
    657         <div class="jd-descrdiv">Simulates a short press on the SEARCH button.</div>
    658 
    659   </td></tr>
    660 
    661 
    662 
    663     <tr class="api" >
    664         <td class="jd-typecol"><nobr>
    665 
    666 
    667 
    668 
    669 
    670             void</nobr>
    671         </td>
    672         <td class="jd-linkcol" width="100%"><nobr>
    673         <span class="sympad"><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher</a></span>(String name, <a href="UiWatcher.html">UiWatcher</a> watcher)</nobr>
    674 
    675         <div class="jd-descrdiv">Registers a <code><a href="UiWatcher.html">UiWatcher</a></code> to run automatically when the testing framework is unable to
    676  find a match using a <code><a href="UiSelector.html">UiSelector</a></code>.</div>
    677 
    678   </td></tr>
    679 
    680 
    681 
    682     <tr class="api" >
    683         <td class="jd-typecol"><nobr>
    684 
    685 
    686 
    687 
    688 
    689             void</nobr>
    690         </td>
    691         <td class="jd-linkcol" width="100%"><nobr>
    692         <span class="sympad"><a href="#removeWatcher(java.lang.String)">removeWatcher</a></span>(String name)</nobr>
    693 
    694         <div class="jd-descrdiv">Removes a previously registered <code><a href="UiWatcher.html">UiWatcher</a></code>.</div>
    695 
    696   </td></tr>
    697 
    698 
    699 
    700     <tr class="api" >
    701         <td class="jd-typecol"><nobr>
    702 
    703 
    704 
    705 
    706 
    707             void</nobr>
    708         </td>
    709         <td class="jd-linkcol" width="100%"><nobr>
    710         <span class="sympad"><a href="#resetWatcherTriggers()">resetWatcherTriggers</a></span>()</nobr>
    711 
    712         <div class="jd-descrdiv">Resets a <code><a href="UiWatcher.html">UiWatcher</a></code> that has been triggered.</div>
    713 
    714   </td></tr>
    715 
    716 
    717 
    718     <tr class="api" >
    719         <td class="jd-typecol"><nobr>
    720 
    721 
    722 
    723 
    724 
    725             void</nobr>
    726         </td>
    727         <td class="jd-linkcol" width="100%"><nobr>
    728         <span class="sympad"><a href="#runWatchers()">runWatchers</a></span>()</nobr>
    729 
    730         <div class="jd-descrdiv">This method forces all registered watchers to run.</div>
    731 
    732   </td></tr>
    733 
    734 
    735 
    736     <tr class="api" >
    737         <td class="jd-typecol"><nobr>
    738 
    739 
    740 
    741 
    742 
    743             void</nobr>
    744         </td>
    745         <td class="jd-linkcol" width="100%"><nobr>
    746         <span class="sympad"><a href="#setCompressedLayoutHeirarchy(boolean)">setCompressedLayoutHeirarchy</a></span>(boolean compressed)</nobr>
    747 
    748         <div class="jd-descrdiv">Enables or disables layout hierarchy compression.</div>
    749 
    750   </td></tr>
    751 
    752 
    753 
    754     <tr class="api" >
    755         <td class="jd-typecol"><nobr>
    756 
    757 
    758 
    759 
    760 
    761             void</nobr>
    762         </td>
    763         <td class="jd-linkcol" width="100%"><nobr>
    764         <span class="sympad"><a href="#setOrientationLeft()">setOrientationLeft</a></span>()</nobr>
    765 
    766         <div class="jd-descrdiv">Simulates orienting the device to the left and also freezes rotation
    767  by disabling the sensors.</div>
    768 
    769   </td></tr>
    770 
    771 
    772 
    773     <tr class="api" >
    774         <td class="jd-typecol"><nobr>
    775 
    776 
    777 
    778 
    779 
    780             void</nobr>
    781         </td>
    782         <td class="jd-linkcol" width="100%"><nobr>
    783         <span class="sympad"><a href="#setOrientationNatural()">setOrientationNatural</a></span>()</nobr>
    784 
    785         <div class="jd-descrdiv">Simulates orienting the device into its natural orientation and also freezes rotation
    786  by disabling the sensors.</div>
    787 
    788   </td></tr>
    789 
    790 
    791 
    792     <tr class="api" >
    793         <td class="jd-typecol"><nobr>
    794 
    795 
    796 
    797 
    798 
    799             void</nobr>
    800         </td>
    801         <td class="jd-linkcol" width="100%"><nobr>
    802         <span class="sympad"><a href="#setOrientationRight()">setOrientationRight</a></span>()</nobr>
    803 
    804         <div class="jd-descrdiv">Simulates orienting the device to the right and also freezes rotation
    805  by disabling the sensors.</div>
    806 
    807   </td></tr>
    808 
    809 
    810 
    811     <tr class="api" >
    812         <td class="jd-typecol"><nobr>
    813 
    814 
    815 
    816 
    817 
    818             void</nobr>
    819         </td>
    820         <td class="jd-linkcol" width="100%"><nobr>
    821         <span class="sympad"><a href="#sleep()">sleep</a></span>()</nobr>
    822 
    823         <div class="jd-descrdiv">This method simply presses the power button if the screen is ON else
    824  it does nothing if the screen is already OFF.</div>
    825 
    826   </td></tr>
    827 
    828 
    829 
    830     <tr class="api" >
    831         <td class="jd-typecol"><nobr>
    832 
    833 
    834 
    835 
    836 
    837             boolean</nobr>
    838         </td>
    839         <td class="jd-linkcol" width="100%"><nobr>
    840         <span class="sympad"><a href="#swipe(android.graphics.Point[], int)">swipe</a></span>(Point[] segments, int segmentSteps)</nobr>
    841 
    842         <div class="jd-descrdiv">Performs a swipe between points in the Point array.</div>
    843 
    844   </td></tr>
    845 
    846 
    847 
    848     <tr class="api" >
    849         <td class="jd-typecol"><nobr>
    850 
    851 
    852 
    853 
    854 
    855             boolean</nobr>
    856         </td>
    857         <td class="jd-linkcol" width="100%"><nobr>
    858         <span class="sympad"><a href="#swipe(int, int, int, int, int)">swipe</a></span>(int startX, int startY, int endX, int endY, int steps)</nobr>
    859 
    860         <div class="jd-descrdiv">Performs a swipe from one coordinate to another using the number of steps
    861  to determine smoothness and speed.</div>
    862 
    863   </td></tr>
    864 
    865 
    866 
    867     <tr class="api" >
    868         <td class="jd-typecol"><nobr>
    869 
    870 
    871 
    872 
    873 
    874             boolean</nobr>
    875         </td>
    876         <td class="jd-linkcol" width="100%"><nobr>
    877         <span class="sympad"><a href="#takeScreenshot(java.io.File)">takeScreenshot</a></span>(File storePath)</nobr>
    878 
    879         <div class="jd-descrdiv">Take a screenshot of current window and store it as PNG
    880 
    881  Default scale of 1.0f (original size) and 90% quality is used
    882  The screenshot is adjusted per screen rotation</div>
    883 
    884   </td></tr>
    885 
    886 
    887 
    888     <tr class="api" >
    889         <td class="jd-typecol"><nobr>
    890 
    891 
    892 
    893 
    894 
    895             boolean</nobr>
    896         </td>
    897         <td class="jd-linkcol" width="100%"><nobr>
    898         <span class="sympad"><a href="#takeScreenshot(java.io.File, float, int)">takeScreenshot</a></span>(File storePath, float scale, int quality)</nobr>
    899 
    900         <div class="jd-descrdiv">Take a screenshot of current window and store it as PNG
    901 
    902  The screenshot is adjusted per screen rotation</div>
    903 
    904   </td></tr>
    905 
    906 
    907 
    908     <tr class="api" >
    909         <td class="jd-typecol"><nobr>
    910 
    911 
    912 
    913 
    914 
    915             void</nobr>
    916         </td>
    917         <td class="jd-linkcol" width="100%"><nobr>
    918         <span class="sympad"><a href="#unfreezeRotation()">unfreezeRotation</a></span>()</nobr>
    919 
    920         <div class="jd-descrdiv">Re-enables the sensors and un-freezes the device rotation allowing its contents
    921  to rotate with the device physical rotation.</div>
    922 
    923   </td></tr>
    924 
    925 
    926 
    927     <tr class="api" >
    928         <td class="jd-typecol"><nobr>
    929 
    930 
    931 
    932 
    933 
    934             void</nobr>
    935         </td>
    936         <td class="jd-linkcol" width="100%"><nobr>
    937         <span class="sympad"><a href="#waitForIdle(long)">waitForIdle</a></span>(long timeout)</nobr>
    938 
    939         <div class="jd-descrdiv">Waits for the current application to idle.</div>
    940 
    941   </td></tr>
    942 
    943 
    944 
    945     <tr class="api" >
    946         <td class="jd-typecol"><nobr>
    947 
    948 
    949 
    950 
    951 
    952             void</nobr>
    953         </td>
    954         <td class="jd-linkcol" width="100%"><nobr>
    955         <span class="sympad"><a href="#waitForIdle()">waitForIdle</a></span>()</nobr>
    956 
    957         <div class="jd-descrdiv">Waits for the current application to idle.</div>
    958 
    959   </td></tr>
    960 
    961 
    962 
    963     <tr class="api" >
    964         <td class="jd-typecol"><nobr>
    965 
    966 
    967 
    968 
    969 
    970             boolean</nobr>
    971         </td>
    972         <td class="jd-linkcol" width="100%"><nobr>
    973         <span class="sympad"><a href="#waitForWindowUpdate(java.lang.String, long)">waitForWindowUpdate</a></span>(String packageName, long timeout)</nobr>
    974 
    975         <div class="jd-descrdiv">Waits for a window content update event to occur.</div>
    976 
    977   </td></tr>
    978 
    979 
    980 
    981     <tr class="api" >
    982         <td class="jd-typecol"><nobr>
    983 
    984 
    985 
    986 
    987 
    988             void</nobr>
    989         </td>
    990         <td class="jd-linkcol" width="100%"><nobr>
    991         <span class="sympad"><a href="#wakeUp()">wakeUp</a></span>()</nobr>
    992 
    993         <div class="jd-descrdiv">This method simulates pressing the power button if the screen is OFF else
    994  it does nothing if the screen is already ON.</div>
    995 
    996   </td></tr>
    997 
    998 
    999 
   1000 </table>
   1001 
   1002 
   1003 
   1004 
   1005 
   1006 
   1007 
   1008 <!-- ========== METHOD SUMMARY =========== -->
   1009 <table id="inhmethods" class="jd-sumtable"><tr><th>
   1010   <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
   1011   <div style="clear:left;">Inherited Methods</div></th></tr>
   1012 
   1013 
   1014 <tr class="api" >
   1015 <td colspan="12">
   1016   <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed"
   1017           ><img id="inherited-methods-java.lang.Object-trigger"
   1018           src="../../../../../assets/images/triangle-closed.png"
   1019           class="jd-expando-trigger-img" /></a>
   1020 From class
   1021 
   1022   java.lang.Object
   1023 
   1024 <div id="inherited-methods-java.lang.Object">
   1025   <div id="inherited-methods-java.lang.Object-list"
   1026         class="jd-inheritedlinks">
   1027   </div>
   1028   <div id="inherited-methods-java.lang.Object-summary" style="display: none;">
   1029     <table class="jd-sumtable-expando">
   1030 
   1031 
   1032 
   1033 
   1034     <tr class="api" >
   1035         <td class="jd-typecol"><nobr>
   1036 
   1037 
   1038 
   1039 
   1040 
   1041             Object</nobr>
   1042         </td>
   1043         <td class="jd-linkcol" width="100%"><nobr>
   1044         <span class="sympad">clone</span>()</nobr>
   1045 
   1046   </td></tr>
   1047 
   1048 
   1049 
   1050     <tr class="api" >
   1051         <td class="jd-typecol"><nobr>
   1052 
   1053 
   1054 
   1055 
   1056 
   1057             boolean</nobr>
   1058         </td>
   1059         <td class="jd-linkcol" width="100%"><nobr>
   1060         <span class="sympad">equals</span>(Object arg0)</nobr>
   1061 
   1062   </td></tr>
   1063 
   1064 
   1065 
   1066     <tr class="api" >
   1067         <td class="jd-typecol"><nobr>
   1068 
   1069 
   1070 
   1071 
   1072 
   1073             void</nobr>
   1074         </td>
   1075         <td class="jd-linkcol" width="100%"><nobr>
   1076         <span class="sympad">finalize</span>()</nobr>
   1077 
   1078   </td></tr>
   1079 
   1080 
   1081 
   1082     <tr class="api" >
   1083         <td class="jd-typecol"><nobr>
   1084 
   1085 
   1086             final
   1087 
   1088 
   1089             Class&lt;?&gt;</nobr>
   1090         </td>
   1091         <td class="jd-linkcol" width="100%"><nobr>
   1092         <span class="sympad">getClass</span>()</nobr>
   1093 
   1094   </td></tr>
   1095 
   1096 
   1097 
   1098     <tr class="api" >
   1099         <td class="jd-typecol"><nobr>
   1100 
   1101 
   1102 
   1103 
   1104 
   1105             int</nobr>
   1106         </td>
   1107         <td class="jd-linkcol" width="100%"><nobr>
   1108         <span class="sympad">hashCode</span>()</nobr>
   1109 
   1110   </td></tr>
   1111 
   1112 
   1113 
   1114     <tr class="api" >
   1115         <td class="jd-typecol"><nobr>
   1116 
   1117 
   1118             final
   1119 
   1120 
   1121             void</nobr>
   1122         </td>
   1123         <td class="jd-linkcol" width="100%"><nobr>
   1124         <span class="sympad">notify</span>()</nobr>
   1125 
   1126   </td></tr>
   1127 
   1128 
   1129 
   1130     <tr class="api" >
   1131         <td class="jd-typecol"><nobr>
   1132 
   1133 
   1134             final
   1135 
   1136 
   1137             void</nobr>
   1138         </td>
   1139         <td class="jd-linkcol" width="100%"><nobr>
   1140         <span class="sympad">notifyAll</span>()</nobr>
   1141 
   1142   </td></tr>
   1143 
   1144 
   1145 
   1146     <tr class="api" >
   1147         <td class="jd-typecol"><nobr>
   1148 
   1149 
   1150 
   1151 
   1152 
   1153             String</nobr>
   1154         </td>
   1155         <td class="jd-linkcol" width="100%"><nobr>
   1156         <span class="sympad">toString</span>()</nobr>
   1157 
   1158   </td></tr>
   1159 
   1160 
   1161 
   1162     <tr class="api" >
   1163         <td class="jd-typecol"><nobr>
   1164 
   1165 
   1166             final
   1167 
   1168 
   1169             void</nobr>
   1170         </td>
   1171         <td class="jd-linkcol" width="100%"><nobr>
   1172         <span class="sympad">wait</span>()</nobr>
   1173 
   1174   </td></tr>
   1175 
   1176 
   1177 
   1178     <tr class="api" >
   1179         <td class="jd-typecol"><nobr>
   1180 
   1181 
   1182             final
   1183 
   1184 
   1185             void</nobr>
   1186         </td>
   1187         <td class="jd-linkcol" width="100%"><nobr>
   1188         <span class="sympad">wait</span>(long arg0, int arg1)</nobr>
   1189 
   1190   </td></tr>
   1191 
   1192 
   1193 
   1194     <tr class="api" >
   1195         <td class="jd-typecol"><nobr>
   1196 
   1197 
   1198             final
   1199 
   1200 
   1201             void</nobr>
   1202         </td>
   1203         <td class="jd-linkcol" width="100%"><nobr>
   1204         <span class="sympad">wait</span>(long arg0)</nobr>
   1205 
   1206   </td></tr>
   1207 
   1208 
   1209 </table>
   1210   </div>
   1211 </div>
   1212 </td></tr>
   1213 
   1214 
   1215 </table>
   1216 
   1217 
   1218 </div><!-- jd-descr (summary) -->
   1219 
   1220 <!-- Details -->
   1221 
   1222 
   1223 
   1224 
   1225 
   1226 
   1227 
   1228 
   1229 <!-- XML Attributes -->
   1230 
   1231 
   1232 <!-- Enum Values -->
   1233 
   1234 
   1235 <!-- Constants -->
   1236 
   1237 
   1238 <!-- Fields -->
   1239 
   1240 
   1241 <!-- Public ctors -->
   1242 
   1243 
   1244 
   1245 <!-- ========= CONSTRUCTOR DETAIL ======== -->
   1246 <!-- Protected ctors -->
   1247 
   1248 
   1249 
   1250 <!-- ========= METHOD DETAIL ======== -->
   1251 <!-- Public methdos -->
   1252 
   1253 <h2>Public Methods</h2>
   1254 
   1255 
   1256 
   1257 <A NAME="clearLastTraversedText()"></A>
   1258 
   1259 <div class="jd-details api">
   1260     <h4 class="jd-details-title">
   1261       <span class="normal">
   1262         public
   1263 
   1264 
   1265 
   1266 
   1267         void
   1268       </span>
   1269       <span class="sympad">clearLastTraversedText</span>
   1270       <span class="normal">()</span>
   1271     </h4>
   1272       <div class="api-level">
   1273         <div></div>
   1274 
   1275 
   1276 
   1277       </div>
   1278     <div class="jd-details-descr">
   1279 
   1280   <div class="jd-tagdata jd-tagdescr"><p>Clears the text from the last UI traversal event.
   1281  See <code><a href="#getLastTraversedText()">getLastTraversedText()</a></code>.</p></div>
   1282 
   1283     </div>
   1284 </div>
   1285 
   1286 
   1287 <A NAME="click(int, int)"></A>
   1288 
   1289 <div class="jd-details api">
   1290     <h4 class="jd-details-title">
   1291       <span class="normal">
   1292         public
   1293 
   1294 
   1295 
   1296 
   1297         boolean
   1298       </span>
   1299       <span class="sympad">click</span>
   1300       <span class="normal">(int x, int y)</span>
   1301     </h4>
   1302       <div class="api-level">
   1303         <div></div>
   1304 
   1305 
   1306 
   1307       </div>
   1308     <div class="jd-details-descr">
   1309 
   1310   <div class="jd-tagdata jd-tagdescr"><p>Perform a click at arbitrary coordinates specified by the user</p></div>
   1311   <div class="jd-tagdata">
   1312       <h5 class="jd-tagtitle">Parameters</h5>
   1313       <table class="jd-tagtable">
   1314         <tr>
   1315           <th>x</td>
   1316           <td>coordinate</td>
   1317         </tr>
   1318         <tr>
   1319           <th>y</td>
   1320           <td>coordinate</td>
   1321         </tr>
   1322       </table>
   1323   </div>
   1324   <div class="jd-tagdata">
   1325       <h5 class="jd-tagtitle">Returns</h5>
   1326       <ul class="nolist"><li>true if the click succeeded else false</li></ul>
   1327   </div>
   1328 
   1329     </div>
   1330 </div>
   1331 
   1332 
   1333 <A NAME="drag(int, int, int, int, int)"></A>
   1334 
   1335 <div class="jd-details api apilevel-18">
   1336     <h4 class="jd-details-title">
   1337       <span class="normal">
   1338         public
   1339 
   1340 
   1341 
   1342 
   1343         boolean
   1344       </span>
   1345       <span class="sympad">drag</span>
   1346       <span class="normal">(int startX, int startY, int endX, int endY, int steps)</span>
   1347     </h4>
   1348     <div class="jd-details-descr">
   1349 
   1350   <div class="jd-tagdata jd-tagdescr"><p>Performs a swipe from one coordinate to another coordinate. You can control
   1351  the smoothness and speed of the swipe by specifying the number of steps.
   1352  Each step execution is throttled to 5 milliseconds per step, so for a 100
   1353  steps, the swipe will take around 0.5 seconds to complete.</p></div>
   1354   <div class="jd-tagdata">
   1355       <h5 class="jd-tagtitle">Parameters</h5>
   1356       <table class="jd-tagtable">
   1357         <tr>
   1358           <th>startX</td>
   1359           <td>X-axis value for the starting coordinate</td>
   1360         </tr>
   1361         <tr>
   1362           <th>startY</td>
   1363           <td>Y-axis value for the starting coordinate</td>
   1364         </tr>
   1365         <tr>
   1366           <th>endX</td>
   1367           <td>X-axis value for the ending coordinate</td>
   1368         </tr>
   1369         <tr>
   1370           <th>endY</td>
   1371           <td>Y-axis value for the ending coordinate</td>
   1372         </tr>
   1373         <tr>
   1374           <th>steps</td>
   1375           <td>is the number of steps for the swipe action</td>
   1376         </tr>
   1377       </table>
   1378   </div>
   1379   <div class="jd-tagdata">
   1380       <h5 class="jd-tagtitle">Returns</h5>
   1381       <ul class="nolist"><li>true if swipe is performed, false if the operation fails
   1382  or the coordinates are invalid</li></ul>
   1383   </div>
   1384   <div class="jd-tagdata">
   1385      <h5 class="jd-tagtitle">Since</h5>
   1386      <ul class="nolist"><li>Android API Level 18</li></ul>
   1387   </div>
   1388     </div>
   1389 </div>
   1390 
   1391 
   1392 <A NAME="dumpWindowHierarchy(java.lang.String)"></A>
   1393 
   1394 <div class="jd-details api">
   1395     <h4 class="jd-details-title">
   1396       <span class="normal">
   1397         public
   1398 
   1399 
   1400 
   1401 
   1402         void
   1403       </span>
   1404       <span class="sympad">dumpWindowHierarchy</span>
   1405       <span class="normal">(String fileName)</span>
   1406     </h4>
   1407       <div class="api-level">
   1408         <div></div>
   1409 
   1410 
   1411 
   1412       </div>
   1413     <div class="jd-details-descr">
   1414 
   1415   <div class="jd-tagdata jd-tagdescr"><p>Helper method used for debugging to dump the current window's layout hierarchy.
   1416  The file root location is /data/local/tmp</p></div>
   1417 
   1418     </div>
   1419 </div>
   1420 
   1421 
   1422 <A NAME="freezeRotation()"></A>
   1423 
   1424 <div class="jd-details api">
   1425     <h4 class="jd-details-title">
   1426       <span class="normal">
   1427         public
   1428 
   1429 
   1430 
   1431 
   1432         void
   1433       </span>
   1434       <span class="sympad">freezeRotation</span>
   1435       <span class="normal">()</span>
   1436     </h4>
   1437       <div class="api-level">
   1438         <div></div>
   1439 
   1440 
   1441 
   1442       </div>
   1443     <div class="jd-details-descr">
   1444 
   1445   <div class="jd-tagdata jd-tagdescr"><p>Disables the sensors and freezes the device rotation at its
   1446  current rotation state.</p></div>
   1447   <div class="jd-tagdata">
   1448       <h5 class="jd-tagtitle">Throws</h5>
   1449       <table class="jd-tagtable">
   1450         <tr>
   1451             <th></td>
   1452             <td>RemoteException</td>
   1453         </tr>
   1454         <tr>
   1455             <th>RemoteException</td>
   1456             <td></td>
   1457         </tr>
   1458       </table>
   1459   </div>
   1460 
   1461     </div>
   1462 </div>
   1463 
   1464 
   1465 <A NAME="getCurrentActivityName()"></A>
   1466 
   1467 <div class="jd-details api">
   1468     <h4 class="jd-details-title">
   1469       <span class="normal">
   1470         public
   1471 
   1472 
   1473 
   1474 
   1475         String
   1476       </span>
   1477       <span class="sympad">getCurrentActivityName</span>
   1478       <span class="normal">()</span>
   1479     </h4>
   1480       <div class="api-level">
   1481         <div></div>
   1482 
   1483 
   1484 
   1485       </div>
   1486     <div class="jd-details-descr">
   1487       <p>
   1488   <p class="caution"><strong>
   1489       This method is deprecated.</strong><br/>
   1490     The results returned should be considered unreliable
   1491   </p>
   1492   <div class="jd-tagdata jd-tagdescr"><p>Retrieves the last activity to report accessibility events.</p></div>
   1493   <div class="jd-tagdata">
   1494       <h5 class="jd-tagtitle">Returns</h5>
   1495       <ul class="nolist"><li>String name of activity</li></ul>
   1496   </div>
   1497 
   1498     </div>
   1499 </div>
   1500 
   1501 
   1502 <A NAME="getCurrentPackageName()"></A>
   1503 
   1504 <div class="jd-details api">
   1505     <h4 class="jd-details-title">
   1506       <span class="normal">
   1507         public
   1508 
   1509 
   1510 
   1511 
   1512         String
   1513       </span>
   1514       <span class="sympad">getCurrentPackageName</span>
   1515       <span class="normal">()</span>
   1516     </h4>
   1517       <div class="api-level">
   1518         <div></div>
   1519 
   1520 
   1521 
   1522       </div>
   1523     <div class="jd-details-descr">
   1524 
   1525   <div class="jd-tagdata jd-tagdescr"><p>Retrieves the name of the last package to report accessibility events.</p></div>
   1526   <div class="jd-tagdata">
   1527       <h5 class="jd-tagtitle">Returns</h5>
   1528       <ul class="nolist"><li>String name of package</li></ul>
   1529   </div>
   1530 
   1531     </div>
   1532 </div>
   1533 
   1534 
   1535 <A NAME="getDisplayHeight()"></A>
   1536 
   1537 <div class="jd-details api">
   1538     <h4 class="jd-details-title">
   1539       <span class="normal">
   1540         public
   1541 
   1542 
   1543 
   1544 
   1545         int
   1546       </span>
   1547       <span class="sympad">getDisplayHeight</span>
   1548       <span class="normal">()</span>
   1549     </h4>
   1550       <div class="api-level">
   1551         <div></div>
   1552 
   1553 
   1554 
   1555       </div>
   1556     <div class="jd-details-descr">
   1557 
   1558   <div class="jd-tagdata jd-tagdescr"><p>Gets the height of the display, in pixels. The size is adjusted based
   1559  on the current orientation of the display.</p></div>
   1560   <div class="jd-tagdata">
   1561       <h5 class="jd-tagtitle">Returns</h5>
   1562       <ul class="nolist"><li>height in pixels or zero on failure</li></ul>
   1563   </div>
   1564 
   1565     </div>
   1566 </div>
   1567 
   1568 
   1569 <A NAME="getDisplayRotation()"></A>
   1570 
   1571 <div class="jd-details api">
   1572     <h4 class="jd-details-title">
   1573       <span class="normal">
   1574         public
   1575 
   1576 
   1577 
   1578 
   1579         int
   1580       </span>
   1581       <span class="sympad">getDisplayRotation</span>
   1582       <span class="normal">()</span>
   1583     </h4>
   1584     <div class="jd-details-descr">
   1585 
   1586   <div class="jd-tagdata jd-tagdescr"><p>Returns the current rotation of the display, as defined in <code><a href="../../../../../reference/android/view/Surface.html">Surface</a></code></p></div>
   1587 
   1588     </div>
   1589     <div class="jd-tagdata">
   1590      <h5 class="jd-tagtitle">Since</h5>
   1591      <ul class="nolist"><li>Android API Level 17</li></ul>
   1592   </div>
   1593 </div>
   1594 
   1595 
   1596 <A NAME="getDisplaySizeDp()"></A>
   1597 
   1598 <div class="jd-details api apilevel-18">
   1599     <h4 class="jd-details-title">
   1600       <span class="normal">
   1601         public
   1602 
   1603 
   1604 
   1605 
   1606         Point
   1607       </span>
   1608       <span class="sympad">getDisplaySizeDp</span>
   1609       <span class="normal">()</span>
   1610     </h4>
   1611     <div class="jd-details-descr">
   1612 
   1613   <div class="jd-tagdata jd-tagdescr"><p>Returns the display size in dp (device-independent pixel)
   1614 
   1615  The returned display size is adjusted per screen rotation. Also this will return the actual
   1616  size of the screen, rather than adjusted per system decorations (like status bar).</p></div>
   1617   <div class="jd-tagdata">
   1618       <h5 class="jd-tagtitle">Returns</h5>
   1619       <ul class="nolist"><li>a Point containing the display size in dp
   1620 </li></ul>
   1621   </div>
   1622   <div class="jd-tagdata">
   1623      <h5 class="jd-tagtitle">Since</h5>
   1624      <ul class="nolist"><li>Android API Level 18</li></ul>
   1625   </div>
   1626     </div>
   1627 </div>
   1628 
   1629 
   1630 <A NAME="getDisplayWidth()"></A>
   1631 
   1632 <div class="jd-details api">
   1633     <h4 class="jd-details-title">
   1634       <span class="normal">
   1635         public
   1636 
   1637 
   1638 
   1639 
   1640         int
   1641       </span>
   1642       <span class="sympad">getDisplayWidth</span>
   1643       <span class="normal">()</span>
   1644     </h4>
   1645     <div class="jd-details-descr">
   1646 
   1647   <div class="jd-tagdata jd-tagdescr"><p>Gets the width of the display, in pixels. The width and height details
   1648  are reported based on the current orientation of the display.</p></div>
   1649   <div class="jd-tagdata">
   1650       <h5 class="jd-tagtitle">Returns</h5>
   1651       <ul class="nolist"><li>width in pixels or zero on failure</li></ul>
   1652   </div>
   1653 
   1654     </div>
   1655 </div>
   1656 
   1657 
   1658 <A NAME="getInstance()"></A>
   1659 
   1660 <div class="jd-details api">
   1661     <h4 class="jd-details-title">
   1662       <span class="normal">
   1663         public
   1664         static
   1665 
   1666 
   1667 
   1668         <a href="#">UiDevice</a>
   1669       </span>
   1670       <span class="sympad">getInstance</span>
   1671       <span class="normal">()</span>
   1672     </h4>
   1673     <div class="jd-details-descr">
   1674 
   1675   <div class="jd-tagdata jd-tagdescr"><p>Retrieves a singleton instance of UiDevice</p></div>
   1676   <div class="jd-tagdata">
   1677       <h5 class="jd-tagtitle">Returns</h5>
   1678       <ul class="nolist"><li>UiDevice instance</li></ul>
   1679   </div>
   1680 
   1681     </div>
   1682 </div>
   1683 
   1684 
   1685 <A NAME="getLastTraversedText()"></A>
   1686 
   1687 <div class="jd-details api">
   1688     <h4 class="jd-details-title">
   1689       <span class="normal">
   1690         public
   1691 
   1692 
   1693 
   1694 
   1695         String
   1696       </span>
   1697       <span class="sympad">getLastTraversedText</span>
   1698       <span class="normal">()</span>
   1699     </h4>
   1700       <div class="api-level">
   1701         <div></div>
   1702 
   1703 
   1704 
   1705       </div>
   1706     <div class="jd-details-descr">
   1707 
   1708   <div class="jd-tagdata jd-tagdescr"><p>Retrieves the text from the last UI traversal event received.
   1709 
   1710  You can use this method to read the contents in a WebView container
   1711  because the accessibility framework fires events
   1712  as each text is highlighted. You can write a test to perform
   1713  directional arrow presses to focus on different elements inside a WebView,
   1714  and call this method to get the text from each traversed element.
   1715  If you are testing a view container that can return a reference to a
   1716  Document Object Model (DOM) object, your test should use the view's
   1717  DOM instead.</p></div>
   1718   <div class="jd-tagdata">
   1719       <h5 class="jd-tagtitle">Returns</h5>
   1720       <ul class="nolist"><li>text of the last traversal event, else return an empty string</li></ul>
   1721   </div>
   1722 
   1723     </div>
   1724 </div>
   1725 
   1726 
   1727 <A NAME="getProductName()"></A>
   1728 
   1729 <div class="jd-details api apilevel-17">
   1730     <h4 class="jd-details-title">
   1731       <span class="normal">
   1732         public
   1733 
   1734 
   1735 
   1736 
   1737         String
   1738       </span>
   1739       <span class="sympad">getProductName</span>
   1740       <span class="normal">()</span>
   1741     </h4>
   1742     <div class="jd-details-descr">
   1743 
   1744   <div class="jd-tagdata jd-tagdescr"><p>Retrieves the product name of the device.
   1745 
   1746  This method provides information on what type of device the test is running on. This value is
   1747  the same as returned by invoking #adb shell getprop ro.product.name.</p></div>
   1748   <div class="jd-tagdata">
   1749       <h5 class="jd-tagtitle">Returns</h5>
   1750       <ul class="nolist"><li>product name of the device</li></ul>
   1751   </div>
   1752   <div class="jd-tagdata">
   1753      <h5 class="jd-tagtitle">Since</h5>
   1754      <ul class="nolist"><li>Android API Level 17</li></ul>
   1755   </div>
   1756     </div>
   1757 </div>
   1758 
   1759 
   1760 <A NAME="hasAnyWatcherTriggered()"></A>
   1761 
   1762 <div class="jd-details api">
   1763     <h4 class="jd-details-title">
   1764       <span class="normal">
   1765         public
   1766 
   1767 
   1768 
   1769 
   1770         boolean
   1771       </span>
   1772       <span class="sympad">hasAnyWatcherTriggered</span>
   1773       <span class="normal">()</span>
   1774     </h4>
   1775       <div class="api-level">
   1776         <div></div>
   1777 
   1778 
   1779 
   1780       </div>
   1781     <div class="jd-details-descr">
   1782 
   1783   <div class="jd-tagdata jd-tagdescr"><p>Checks if any registered <code><a href="UiWatcher.html">UiWatcher</a></code> have triggered.
   1784 
   1785  See <code><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher(String, UiWatcher)</a></code>
   1786  See <code><a href="#hasWatcherTriggered(java.lang.String)">hasWatcherTriggered(String)</a></code></p></div>
   1787 
   1788     </div>
   1789 </div>
   1790 
   1791 
   1792 <A NAME="hasWatcherTriggered(java.lang.String)"></A>
   1793 
   1794 <div class="jd-details api">
   1795     <h4 class="jd-details-title">
   1796       <span class="normal">
   1797         public
   1798 
   1799 
   1800 
   1801 
   1802         boolean
   1803       </span>
   1804       <span class="sympad">hasWatcherTriggered</span>
   1805       <span class="normal">(String watcherName)</span>
   1806     </h4>
   1807       <div class="api-level">
   1808         <div></div>
   1809 
   1810 
   1811 
   1812       </div>
   1813     <div class="jd-details-descr">
   1814 
   1815   <div class="jd-tagdata jd-tagdescr"><p>Checks if a specific registered  <code><a href="UiWatcher.html">UiWatcher</a></code> has triggered.
   1816  See <code><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher(String, UiWatcher)</a></code>. If a UiWatcher runs and its
   1817  <code><a href="UiWatcher.html#checkForCondition()">checkForCondition()</a></code> call returned <code>true</code>, then
   1818  the UiWatcher is considered triggered. This is helpful if a watcher is detecting errors
   1819  from ANR or crash dialogs and the test needs to know if a UiWatcher has been triggered.</p></div>
   1820   <div class="jd-tagdata">
   1821       <h5 class="jd-tagtitle">Returns</h5>
   1822       <ul class="nolist"><li>true if triggered else false</li></ul>
   1823   </div>
   1824 
   1825     </div>
   1826 </div>
   1827 
   1828 
   1829 <A NAME="isNaturalOrientation()"></A>
   1830 
   1831 <div class="jd-details api">
   1832     <h4 class="jd-details-title">
   1833       <span class="normal">
   1834         public
   1835 
   1836 
   1837 
   1838 
   1839         boolean
   1840       </span>
   1841       <span class="sympad">isNaturalOrientation</span>
   1842       <span class="normal">()</span>
   1843     </h4>
   1844     <div class="jd-details-descr">
   1845 
   1846   <div class="jd-tagdata jd-tagdescr"><p>Check if the device is in its natural orientation. This is determined by checking if the
   1847  orientation is at 0 or 180 degrees.</p></div>
   1848   <div class="jd-tagdata">
   1849       <h5 class="jd-tagtitle">Returns</h5>
   1850       <ul class="nolist"><li>true if it is in natural orientation</li></ul>
   1851   </div>
   1852   <div class="jd-tagdata">
   1853      <h5 class="jd-tagtitle">Since</h5>
   1854      <ul class="nolist"><li>Android API Level 17</li></ul>
   1855   </div>
   1856     </div>
   1857 </div>
   1858 
   1859 
   1860 <A NAME="isScreenOn()"></A>
   1861 
   1862 <div class="jd-details api">
   1863     <h4 class="jd-details-title">
   1864       <span class="normal">
   1865         public
   1866 
   1867 
   1868 
   1869 
   1870         boolean
   1871       </span>
   1872       <span class="sympad">isScreenOn</span>
   1873       <span class="normal">()</span>
   1874     </h4>
   1875       <div class="api-level">
   1876         <div></div>
   1877 
   1878 
   1879 
   1880       </div>
   1881     <div class="jd-details-descr">
   1882 
   1883   <div class="jd-tagdata jd-tagdescr"><p>Checks the power manager if the screen is ON.</p></div>
   1884   <div class="jd-tagdata">
   1885       <h5 class="jd-tagtitle">Returns</h5>
   1886       <ul class="nolist"><li>true if the screen is ON else false</li></ul>
   1887   </div>
   1888   <div class="jd-tagdata">
   1889       <h5 class="jd-tagtitle">Throws</h5>
   1890       <table class="jd-tagtable">
   1891         <tr>
   1892             <th></td>
   1893             <td>RemoteException</td>
   1894         </tr>
   1895         <tr>
   1896             <th>RemoteException</td>
   1897             <td></td>
   1898         </tr>
   1899       </table>
   1900   </div>
   1901 
   1902     </div>
   1903 </div>
   1904 
   1905 
   1906 <A NAME="openNotification()"></A>
   1907 
   1908 <div class="jd-details api apilevel-18">
   1909     <h4 class="jd-details-title">
   1910       <span class="normal">
   1911         public
   1912 
   1913 
   1914 
   1915 
   1916         boolean
   1917       </span>
   1918       <span class="sympad">openNotification</span>
   1919       <span class="normal">()</span>
   1920     </h4>
   1921     <div class="jd-details-descr">
   1922 
   1923   <div class="jd-tagdata jd-tagdescr"><p>Opens the notification shade.</p></div>
   1924   <div class="jd-tagdata">
   1925       <h5 class="jd-tagtitle">Returns</h5>
   1926       <ul class="nolist"><li>true if successful, else return false</li></ul>
   1927   </div>
   1928   <div class="jd-tagdata">
   1929      <h5 class="jd-tagtitle">Since</h5>
   1930      <ul class="nolist"><li>Android API Level 18</li></ul>
   1931   </div>
   1932     </div>
   1933 </div>
   1934 
   1935 
   1936 <A NAME="openQuickSettings()"></A>
   1937 
   1938 <div class="jd-details api apilevel-18">
   1939     <h4 class="jd-details-title">
   1940       <span class="normal">
   1941         public
   1942 
   1943 
   1944 
   1945 
   1946         boolean
   1947       </span>
   1948       <span class="sympad">openQuickSettings</span>
   1949       <span class="normal">()</span>
   1950     </h4>
   1951     <div class="jd-details-descr">
   1952 
   1953   <div class="jd-tagdata jd-tagdescr"><p>Opens the Quick Settings shade.</p></div>
   1954   <div class="jd-tagdata">
   1955       <h5 class="jd-tagtitle">Returns</h5>
   1956       <ul class="nolist"><li>true if successful, else return false</li></ul>
   1957   </div>
   1958   <div class="jd-tagdata">
   1959      <h5 class="jd-tagtitle">Since</h5>
   1960      <ul class="nolist"><li>Android API Level 18</li></ul>
   1961   </div>
   1962     </div>
   1963 </div>
   1964 
   1965 
   1966 <A NAME="pressBack()"></A>
   1967 
   1968 <div class="jd-details api">
   1969     <h4 class="jd-details-title">
   1970       <span class="normal">
   1971         public
   1972 
   1973 
   1974 
   1975 
   1976         boolean
   1977       </span>
   1978       <span class="sympad">pressBack</span>
   1979       <span class="normal">()</span>
   1980     </h4>
   1981       <div class="api-level">
   1982         <div></div>
   1983 
   1984 
   1985 
   1986       </div>
   1987     <div class="jd-details-descr">
   1988 
   1989   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the BACK button.</p></div>
   1990   <div class="jd-tagdata">
   1991       <h5 class="jd-tagtitle">Returns</h5>
   1992       <ul class="nolist"><li>true if successful, else return false</li></ul>
   1993   </div>
   1994 
   1995     </div>
   1996 </div>
   1997 
   1998 
   1999 <A NAME="pressDPadCenter()"></A>
   2000 
   2001 <div class="jd-details api">
   2002     <h4 class="jd-details-title">
   2003       <span class="normal">
   2004         public
   2005 
   2006 
   2007 
   2008 
   2009         boolean
   2010       </span>
   2011       <span class="sympad">pressDPadCenter</span>
   2012       <span class="normal">()</span>
   2013     </h4>
   2014       <div class="api-level">
   2015         <div></div>
   2016 
   2017 
   2018 
   2019       </div>
   2020     <div class="jd-details-descr">
   2021 
   2022   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the CENTER button.</p></div>
   2023   <div class="jd-tagdata">
   2024       <h5 class="jd-tagtitle">Returns</h5>
   2025       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2026   </div>
   2027 
   2028     </div>
   2029 </div>
   2030 
   2031 
   2032 <A NAME="pressDPadDown()"></A>
   2033 
   2034 <div class="jd-details api">
   2035     <h4 class="jd-details-title">
   2036       <span class="normal">
   2037         public
   2038 
   2039 
   2040 
   2041 
   2042         boolean
   2043       </span>
   2044       <span class="sympad">pressDPadDown</span>
   2045       <span class="normal">()</span>
   2046     </h4>
   2047       <div class="api-level">
   2048         <div></div>
   2049 
   2050 
   2051 
   2052       </div>
   2053     <div class="jd-details-descr">
   2054 
   2055   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the DOWN button.</p></div>
   2056   <div class="jd-tagdata">
   2057       <h5 class="jd-tagtitle">Returns</h5>
   2058       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2059   </div>
   2060 
   2061     </div>
   2062 </div>
   2063 
   2064 
   2065 <A NAME="pressDPadLeft()"></A>
   2066 
   2067 <div class="jd-details api">
   2068     <h4 class="jd-details-title">
   2069       <span class="normal">
   2070         public
   2071 
   2072 
   2073 
   2074 
   2075         boolean
   2076       </span>
   2077       <span class="sympad">pressDPadLeft</span>
   2078       <span class="normal">()</span>
   2079     </h4>
   2080       <div class="api-level">
   2081         <div></div>
   2082 
   2083 
   2084 
   2085       </div>
   2086     <div class="jd-details-descr">
   2087 
   2088   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the LEFT button.</p></div>
   2089   <div class="jd-tagdata">
   2090       <h5 class="jd-tagtitle">Returns</h5>
   2091       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2092   </div>
   2093 
   2094     </div>
   2095 </div>
   2096 
   2097 
   2098 <A NAME="pressDPadRight()"></A>
   2099 
   2100 <div class="jd-details api">
   2101     <h4 class="jd-details-title">
   2102       <span class="normal">
   2103         public
   2104 
   2105 
   2106 
   2107 
   2108         boolean
   2109       </span>
   2110       <span class="sympad">pressDPadRight</span>
   2111       <span class="normal">()</span>
   2112     </h4>
   2113       <div class="api-level">
   2114         <div></div>
   2115 
   2116 
   2117 
   2118       </div>
   2119     <div class="jd-details-descr">
   2120 
   2121   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the RIGHT button.</p></div>
   2122   <div class="jd-tagdata">
   2123       <h5 class="jd-tagtitle">Returns</h5>
   2124       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2125   </div>
   2126 
   2127     </div>
   2128 </div>
   2129 
   2130 
   2131 <A NAME="pressDPadUp()"></A>
   2132 
   2133 <div class="jd-details api">
   2134     <h4 class="jd-details-title">
   2135       <span class="normal">
   2136         public
   2137 
   2138 
   2139 
   2140 
   2141         boolean
   2142       </span>
   2143       <span class="sympad">pressDPadUp</span>
   2144       <span class="normal">()</span>
   2145     </h4>
   2146       <div class="api-level">
   2147         <div></div>
   2148 
   2149 
   2150 
   2151       </div>
   2152     <div class="jd-details-descr">
   2153 
   2154   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the UP button.</p></div>
   2155   <div class="jd-tagdata">
   2156       <h5 class="jd-tagtitle">Returns</h5>
   2157       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2158   </div>
   2159 
   2160     </div>
   2161 </div>
   2162 
   2163 
   2164 <A NAME="pressDelete()"></A>
   2165 
   2166 <div class="jd-details api">
   2167     <h4 class="jd-details-title">
   2168       <span class="normal">
   2169         public
   2170 
   2171 
   2172 
   2173 
   2174         boolean
   2175       </span>
   2176       <span class="sympad">pressDelete</span>
   2177       <span class="normal">()</span>
   2178     </h4>
   2179       <div class="api-level">
   2180         <div></div>
   2181 
   2182 
   2183 
   2184       </div>
   2185     <div class="jd-details-descr">
   2186 
   2187   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the DELETE key.</p></div>
   2188   <div class="jd-tagdata">
   2189       <h5 class="jd-tagtitle">Returns</h5>
   2190       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2191   </div>
   2192 
   2193     </div>
   2194 </div>
   2195 
   2196 
   2197 <A NAME="pressEnter()"></A>
   2198 
   2199 <div class="jd-details api">
   2200     <h4 class="jd-details-title">
   2201       <span class="normal">
   2202         public
   2203 
   2204 
   2205 
   2206 
   2207         boolean
   2208       </span>
   2209       <span class="sympad">pressEnter</span>
   2210       <span class="normal">()</span>
   2211     </h4>
   2212       <div class="api-level">
   2213         <div></div>
   2214 
   2215 
   2216 
   2217       </div>
   2218     <div class="jd-details-descr">
   2219 
   2220   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the ENTER key.</p></div>
   2221   <div class="jd-tagdata">
   2222       <h5 class="jd-tagtitle">Returns</h5>
   2223       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2224   </div>
   2225 
   2226     </div>
   2227 </div>
   2228 
   2229 
   2230 <A NAME="pressHome()"></A>
   2231 
   2232 <div class="jd-details api">
   2233     <h4 class="jd-details-title">
   2234       <span class="normal">
   2235         public
   2236 
   2237 
   2238 
   2239 
   2240         boolean
   2241       </span>
   2242       <span class="sympad">pressHome</span>
   2243       <span class="normal">()</span>
   2244     </h4>
   2245       <div class="api-level">
   2246         <div></div>
   2247 
   2248 
   2249 
   2250       </div>
   2251     <div class="jd-details-descr">
   2252 
   2253   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the HOME button.</p></div>
   2254   <div class="jd-tagdata">
   2255       <h5 class="jd-tagtitle">Returns</h5>
   2256       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2257   </div>
   2258 
   2259     </div>
   2260 </div>
   2261 
   2262 
   2263 <A NAME="pressKeyCode(int, int)"></A>
   2264 
   2265 <div class="jd-details api">
   2266     <h4 class="jd-details-title">
   2267       <span class="normal">
   2268         public
   2269 
   2270 
   2271 
   2272 
   2273         boolean
   2274       </span>
   2275       <span class="sympad">pressKeyCode</span>
   2276       <span class="normal">(int keyCode, int metaState)</span>
   2277     </h4>
   2278       <div class="api-level">
   2279         <div></div>
   2280 
   2281 
   2282 
   2283       </div>
   2284     <div class="jd-details-descr">
   2285 
   2286   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press using a key code.
   2287 
   2288  See <code><a href="../../../../../reference/android/view/KeyEvent.html">KeyEvent</a></code>.</p></div>
   2289   <div class="jd-tagdata">
   2290       <h5 class="jd-tagtitle">Parameters</h5>
   2291       <table class="jd-tagtable">
   2292         <tr>
   2293           <th>keyCode</td>
   2294           <td>the key code of the event.</td>
   2295         </tr>
   2296         <tr>
   2297           <th>metaState</td>
   2298           <td>an integer in which each bit set to 1 represents a pressed meta key</td>
   2299         </tr>
   2300       </table>
   2301   </div>
   2302   <div class="jd-tagdata">
   2303       <h5 class="jd-tagtitle">Returns</h5>
   2304       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2305   </div>
   2306 
   2307     </div>
   2308 </div>
   2309 
   2310 
   2311 <A NAME="pressKeyCode(int)"></A>
   2312 
   2313 <div class="jd-details api">
   2314     <h4 class="jd-details-title">
   2315       <span class="normal">
   2316         public
   2317 
   2318 
   2319 
   2320 
   2321         boolean
   2322       </span>
   2323       <span class="sympad">pressKeyCode</span>
   2324       <span class="normal">(int keyCode)</span>
   2325     </h4>
   2326       <div class="api-level">
   2327         <div></div>
   2328 
   2329 
   2330 
   2331       </div>
   2332     <div class="jd-details-descr">
   2333 
   2334   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press using a key code.
   2335 
   2336  See <code><a href="../../../../../reference/android/view/KeyEvent.html">KeyEvent</a></code></p></div>
   2337   <div class="jd-tagdata">
   2338       <h5 class="jd-tagtitle">Returns</h5>
   2339       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2340   </div>
   2341 
   2342     </div>
   2343 </div>
   2344 
   2345 
   2346 <A NAME="pressMenu()"></A>
   2347 
   2348 <div class="jd-details api">
   2349     <h4 class="jd-details-title">
   2350       <span class="normal">
   2351         public
   2352 
   2353 
   2354 
   2355 
   2356         boolean
   2357       </span>
   2358       <span class="sympad">pressMenu</span>
   2359       <span class="normal">()</span>
   2360     </h4>
   2361       <div class="api-level">
   2362         <div></div>
   2363 
   2364 
   2365 
   2366       </div>
   2367     <div class="jd-details-descr">
   2368 
   2369   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the MENU button.</p></div>
   2370   <div class="jd-tagdata">
   2371       <h5 class="jd-tagtitle">Returns</h5>
   2372       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2373   </div>
   2374 
   2375     </div>
   2376 </div>
   2377 
   2378 
   2379 <A NAME="pressRecentApps()"></A>
   2380 
   2381 <div class="jd-details api">
   2382     <h4 class="jd-details-title">
   2383       <span class="normal">
   2384         public
   2385 
   2386 
   2387 
   2388 
   2389         boolean
   2390       </span>
   2391       <span class="sympad">pressRecentApps</span>
   2392       <span class="normal">()</span>
   2393     </h4>
   2394       <div class="api-level">
   2395         <div></div>
   2396 
   2397 
   2398 
   2399       </div>
   2400     <div class="jd-details-descr">
   2401 
   2402   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the Recent Apps button.</p></div>
   2403   <div class="jd-tagdata">
   2404       <h5 class="jd-tagtitle">Returns</h5>
   2405       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2406   </div>
   2407   <div class="jd-tagdata">
   2408       <h5 class="jd-tagtitle">Throws</h5>
   2409       <table class="jd-tagtable">
   2410         <tr>
   2411             <th></td>
   2412             <td>RemoteException</td>
   2413         </tr>
   2414         <tr>
   2415             <th>RemoteException</td>
   2416             <td></td>
   2417         </tr>
   2418       </table>
   2419   </div>
   2420 
   2421     </div>
   2422 </div>
   2423 
   2424 
   2425 <A NAME="pressSearch()"></A>
   2426 
   2427 <div class="jd-details api">
   2428     <h4 class="jd-details-title">
   2429       <span class="normal">
   2430         public
   2431 
   2432 
   2433 
   2434 
   2435         boolean
   2436       </span>
   2437       <span class="sympad">pressSearch</span>
   2438       <span class="normal">()</span>
   2439     </h4>
   2440       <div class="api-level">
   2441         <div></div>
   2442 
   2443 
   2444 
   2445       </div>
   2446     <div class="jd-details-descr">
   2447 
   2448   <div class="jd-tagdata jd-tagdescr"><p>Simulates a short press on the SEARCH button.</p></div>
   2449   <div class="jd-tagdata">
   2450       <h5 class="jd-tagtitle">Returns</h5>
   2451       <ul class="nolist"><li>true if successful, else return false</li></ul>
   2452   </div>
   2453 
   2454     </div>
   2455 </div>
   2456 
   2457 
   2458 <A NAME="registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)"></A>
   2459 
   2460 <div class="jd-details api">
   2461     <h4 class="jd-details-title">
   2462       <span class="normal">
   2463         public
   2464 
   2465 
   2466 
   2467 
   2468         void
   2469       </span>
   2470       <span class="sympad">registerWatcher</span>
   2471       <span class="normal">(String name, <a href="UiWatcher.html">UiWatcher</a> watcher)</span>
   2472     </h4>
   2473       <div class="api-level">
   2474         <div></div>
   2475 
   2476 
   2477 
   2478       </div>
   2479     <div class="jd-details-descr">
   2480 
   2481   <div class="jd-tagdata jd-tagdescr"><p>Registers a <code><a href="UiWatcher.html">UiWatcher</a></code> to run automatically when the testing framework is unable to
   2482  find a match using a <code><a href="UiSelector.html">UiSelector</a></code>. See <code><a href="#runWatchers()">runWatchers()</a></code></p></div>
   2483   <div class="jd-tagdata">
   2484       <h5 class="jd-tagtitle">Parameters</h5>
   2485       <table class="jd-tagtable">
   2486         <tr>
   2487           <th>name</td>
   2488           <td>to register the UiWatcher</td>
   2489         </tr>
   2490         <tr>
   2491           <th>watcher</td>
   2492           <td><code><a href="UiWatcher.html">UiWatcher</a></code></td>
   2493         </tr>
   2494       </table>
   2495   </div>
   2496 
   2497     </div>
   2498 </div>
   2499 
   2500 
   2501 <A NAME="removeWatcher(java.lang.String)"></A>
   2502 
   2503 <div class="jd-details api">
   2504     <h4 class="jd-details-title">
   2505       <span class="normal">
   2506         public
   2507 
   2508 
   2509 
   2510 
   2511         void
   2512       </span>
   2513       <span class="sympad">removeWatcher</span>
   2514       <span class="normal">(String name)</span>
   2515     </h4>
   2516       <div class="api-level">
   2517         <div></div>
   2518 
   2519 
   2520 
   2521       </div>
   2522     <div class="jd-details-descr">
   2523 
   2524   <div class="jd-tagdata jd-tagdescr"><p>Removes a previously registered <code><a href="UiWatcher.html">UiWatcher</a></code>.
   2525 
   2526  See <code><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p></div>
   2527   <div class="jd-tagdata">
   2528       <h5 class="jd-tagtitle">Parameters</h5>
   2529       <table class="jd-tagtable">
   2530         <tr>
   2531           <th>name</td>
   2532           <td>used to register the UiWatcher</td>
   2533         </tr>
   2534       </table>
   2535   </div>
   2536 
   2537     </div>
   2538 </div>
   2539 
   2540 
   2541 <A NAME="resetWatcherTriggers()"></A>
   2542 
   2543 <div class="jd-details api">
   2544     <h4 class="jd-details-title">
   2545       <span class="normal">
   2546         public
   2547 
   2548 
   2549 
   2550 
   2551         void
   2552       </span>
   2553       <span class="sympad">resetWatcherTriggers</span>
   2554       <span class="normal">()</span>
   2555     </h4>
   2556       <div class="api-level">
   2557         <div></div>
   2558 
   2559 
   2560 
   2561       </div>
   2562     <div class="jd-details-descr">
   2563 
   2564   <div class="jd-tagdata jd-tagdescr"><p>Resets a <code><a href="UiWatcher.html">UiWatcher</a></code> that has been triggered.
   2565  If a UiWatcher runs and its <code><a href="UiWatcher.html#checkForCondition()">checkForCondition()</a></code> call
   2566  returned <code>true</code>, then the UiWatcher is considered triggered.
   2567  See <code><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p></div>
   2568 
   2569     </div>
   2570 </div>
   2571 
   2572 
   2573 <A NAME="runWatchers()"></A>
   2574 
   2575 <div class="jd-details api">
   2576     <h4 class="jd-details-title">
   2577       <span class="normal">
   2578         public
   2579 
   2580 
   2581 
   2582 
   2583         void
   2584       </span>
   2585       <span class="sympad">runWatchers</span>
   2586       <span class="normal">()</span>
   2587     </h4>
   2588       <div class="api-level">
   2589         <div></div>
   2590 
   2591 
   2592 
   2593       </div>
   2594     <div class="jd-details-descr">
   2595 
   2596   <div class="jd-tagdata jd-tagdescr"><p>This method forces all registered watchers to run.
   2597  See <code><a href="#registerWatcher(java.lang.String, com.android.uiautomator.core.UiWatcher)">registerWatcher(String, UiWatcher)</a></code></p></div>
   2598 
   2599     </div>
   2600 </div>
   2601 
   2602 
   2603 <A NAME="setCompressedLayoutHeirarchy(boolean)"></A>
   2604 
   2605 <div class="jd-details api apilevel-18">
   2606     <h4 class="jd-details-title">
   2607       <span class="normal">
   2608         public
   2609 
   2610 
   2611 
   2612 
   2613         void
   2614       </span>
   2615       <span class="sympad">setCompressedLayoutHeirarchy</span>
   2616       <span class="normal">(boolean compressed)</span>
   2617     </h4>
   2618     <div class="jd-details-descr">
   2619 
   2620   <div class="jd-tagdata jd-tagdescr"><p>Enables or disables layout hierarchy compression.
   2621 
   2622  If compression is enabled, the layout hierarchy derived from the Acessibility
   2623  framework will only contain nodes that are important for uiautomator
   2624  testing. Any unnecessary surrounding layout nodes that make viewing
   2625  and searching the hierarchy inefficient are removed.</p></div>
   2626   <div class="jd-tagdata">
   2627       <h5 class="jd-tagtitle">Parameters</h5>
   2628       <table class="jd-tagtable">
   2629         <tr>
   2630           <th>compressed</td>
   2631           <td>true to enable compression; else, false to disable</td>
   2632         </tr>
   2633       </table>
   2634   </div>
   2635   <div class="jd-tagdata">
   2636      <h5 class="jd-tagtitle">Since</h5>
   2637      <ul class="nolist"><li>Android API Level 18</li></ul>
   2638   </div>
   2639     </div>
   2640 </div>
   2641 
   2642 
   2643 <A NAME="setOrientationLeft()"></A>
   2644 
   2645 <div class="jd-details api">
   2646     <h4 class="jd-details-title">
   2647       <span class="normal">
   2648         public
   2649 
   2650 
   2651 
   2652 
   2653         void
   2654       </span>
   2655       <span class="sympad">setOrientationLeft</span>
   2656       <span class="normal">()</span>
   2657     </h4>
   2658     <div class="jd-details-descr">
   2659 
   2660   <div class="jd-tagdata jd-tagdescr"><p>Simulates orienting the device to the left and also freezes rotation
   2661  by disabling the sensors.
   2662 
   2663  If you want to un-freeze the rotation and re-enable the sensors
   2664  see <code><a href="#unfreezeRotation()">unfreezeRotation()</a></code>.</p></div>
   2665   <div class="jd-tagdata">
   2666       <h5 class="jd-tagtitle">Throws</h5>
   2667       <table class="jd-tagtable">
   2668         <tr>
   2669             <th></td>
   2670             <td>RemoteException</td>
   2671         </tr>
   2672         <tr>
   2673             <th>RemoteException</td>
   2674             <td></td>
   2675         </tr>
   2676       </table>
   2677   </div>
   2678   <div class="jd-tagdata">
   2679      <h5 class="jd-tagtitle">Since</h5>
   2680      <ul class="nolist"><li>Android API Level 17</li></ul>
   2681   </div>
   2682     </div>
   2683 </div>
   2684 
   2685 
   2686 <A NAME="setOrientationNatural()"></A>
   2687 
   2688 <div class="jd-details api">
   2689     <h4 class="jd-details-title">
   2690       <span class="normal">
   2691         public
   2692 
   2693 
   2694 
   2695 
   2696         void
   2697       </span>
   2698       <span class="sympad">setOrientationNatural</span>
   2699       <span class="normal">()</span>
   2700     </h4>
   2701     <div class="jd-details-descr">
   2702 
   2703   <div class="jd-tagdata jd-tagdescr"><p>Simulates orienting the device into its natural orientation and also freezes rotation
   2704  by disabling the sensors.
   2705 
   2706  If you want to un-freeze the rotation and re-enable the sensors
   2707  see <code><a href="#unfreezeRotation()">unfreezeRotation()</a></code>.</p></div>
   2708   <div class="jd-tagdata">
   2709       <h5 class="jd-tagtitle">Throws</h5>
   2710       <table class="jd-tagtable">
   2711         <tr>
   2712             <th></td>
   2713             <td>RemoteException</td>
   2714         </tr>
   2715         <tr>
   2716             <th>RemoteException</td>
   2717             <td></td>
   2718         </tr>
   2719       </table>
   2720   </div>
   2721   <div class="jd-tagdata">
   2722      <h5 class="jd-tagtitle">Since</h5>
   2723      <ul class="nolist"><li>Android API Level 17</li></ul>
   2724   </div>
   2725     </div>
   2726 </div>
   2727 
   2728 
   2729 <A NAME="setOrientationRight()"></A>
   2730 
   2731 <div class="jd-details api">
   2732     <h4 class="jd-details-title">
   2733       <span class="normal">
   2734         public
   2735 
   2736 
   2737 
   2738 
   2739         void
   2740       </span>
   2741       <span class="sympad">setOrientationRight</span>
   2742       <span class="normal">()</span>
   2743     </h4>
   2744     <div class="jd-details-descr">
   2745 
   2746   <div class="jd-tagdata jd-tagdescr"><p>Simulates orienting the device to the right and also freezes rotation
   2747  by disabling the sensors.
   2748 
   2749  If you want to un-freeze the rotation and re-enable the sensors
   2750  see <code><a href="#unfreezeRotation()">unfreezeRotation()</a></code>.</p></div>
   2751   <div class="jd-tagdata">
   2752       <h5 class="jd-tagtitle">Throws</h5>
   2753       <table class="jd-tagtable">
   2754         <tr>
   2755             <th></td>
   2756             <td>RemoteException</td>
   2757         </tr>
   2758         <tr>
   2759             <th>RemoteException</td>
   2760             <td></td>
   2761         </tr>
   2762       </table>
   2763   </div>
   2764   <div class="jd-tagdata">
   2765      <h5 class="jd-tagtitle">Since</h5>
   2766      <ul class="nolist"><li>Android API Level 17</li></ul>
   2767   </div>
   2768     </div>
   2769 </div>
   2770 
   2771 
   2772 <A NAME="sleep()"></A>
   2773 
   2774 <div class="jd-details api">
   2775     <h4 class="jd-details-title">
   2776       <span class="normal">
   2777         public
   2778 
   2779 
   2780 
   2781 
   2782         void
   2783       </span>
   2784       <span class="sympad">sleep</span>
   2785       <span class="normal">()</span>
   2786     </h4>
   2787       <div class="api-level">
   2788         <div></div>
   2789 
   2790 
   2791 
   2792       </div>
   2793     <div class="jd-details-descr">
   2794 
   2795   <div class="jd-tagdata jd-tagdescr"><p>This method simply presses the power button if the screen is ON else
   2796  it does nothing if the screen is already OFF.</p></div>
   2797   <div class="jd-tagdata">
   2798       <h5 class="jd-tagtitle">Throws</h5>
   2799       <table class="jd-tagtable">
   2800         <tr>
   2801             <th></td>
   2802             <td>RemoteException</td>
   2803         </tr>
   2804         <tr>
   2805             <th>RemoteException</td>
   2806             <td></td>
   2807         </tr>
   2808       </table>
   2809   </div>
   2810 
   2811     </div>
   2812 </div>
   2813 
   2814 
   2815 <A NAME="swipe(android.graphics.Point[], int)"></A>
   2816 
   2817 <div class="jd-details api">
   2818     <h4 class="jd-details-title">
   2819       <span class="normal">
   2820         public
   2821 
   2822 
   2823 
   2824 
   2825         boolean
   2826       </span>
   2827       <span class="sympad">swipe</span>
   2828       <span class="normal">(Point[] segments, int segmentSteps)</span>
   2829     </h4>
   2830       <div class="api-level">
   2831         <div></div>
   2832 
   2833 
   2834 
   2835       </div>
   2836     <div class="jd-details-descr">
   2837 
   2838   <div class="jd-tagdata jd-tagdescr"><p>Performs a swipe between points in the Point array. Each step execution is throttled
   2839  to 5ms per step. So for a 100 steps, the swipe will take about 1/2 second to complete</p></div>
   2840   <div class="jd-tagdata">
   2841       <h5 class="jd-tagtitle">Parameters</h5>
   2842       <table class="jd-tagtable">
   2843         <tr>
   2844           <th>segments</td>
   2845           <td>is Point array containing at least one Point object</td>
   2846         </tr>
   2847         <tr>
   2848           <th>segmentSteps</td>
   2849           <td>steps to inject between two Points</td>
   2850         </tr>
   2851       </table>
   2852   </div>
   2853   <div class="jd-tagdata">
   2854       <h5 class="jd-tagtitle">Returns</h5>
   2855       <ul class="nolist"><li>true on success</li></ul>
   2856   </div>
   2857 
   2858     </div>
   2859 </div>
   2860 
   2861 
   2862 <A NAME="swipe(int, int, int, int, int)"></A>
   2863 
   2864 <div class="jd-details api">
   2865     <h4 class="jd-details-title">
   2866       <span class="normal">
   2867         public
   2868 
   2869 
   2870 
   2871 
   2872         boolean
   2873       </span>
   2874       <span class="sympad">swipe</span>
   2875       <span class="normal">(int startX, int startY, int endX, int endY, int steps)</span>
   2876     </h4>
   2877       <div class="api-level">
   2878         <div></div>
   2879 
   2880 
   2881 
   2882       </div>
   2883     <div class="jd-details-descr">
   2884 
   2885   <div class="jd-tagdata jd-tagdescr"><p>Performs a swipe from one coordinate to another using the number of steps
   2886  to determine smoothness and speed. Each step execution is throttled to 5ms
   2887  per step. So for a 100 steps, the swipe will take about 1/2 second to complete.</p></div>
   2888   <div class="jd-tagdata">
   2889       <h5 class="jd-tagtitle">Parameters</h5>
   2890       <table class="jd-tagtable">
   2891         <tr>
   2892           <th>steps</td>
   2893           <td>is the number of move steps sent to the system</td>
   2894         </tr>
   2895       </table>
   2896   </div>
   2897   <div class="jd-tagdata">
   2898       <h5 class="jd-tagtitle">Returns</h5>
   2899       <ul class="nolist"><li>false if the operation fails or the coordinates are invalid</li></ul>
   2900   </div>
   2901 
   2902     </div>
   2903 </div>
   2904 
   2905 
   2906 <A NAME="takeScreenshot(java.io.File)"></A>
   2907 
   2908 <div class="jd-details api">
   2909     <h4 class="jd-details-title">
   2910       <span class="normal">
   2911         public
   2912 
   2913 
   2914 
   2915 
   2916         boolean
   2917       </span>
   2918       <span class="sympad">takeScreenshot</span>
   2919       <span class="normal">(File storePath)</span>
   2920     </h4>
   2921     <div class="jd-details-descr">
   2922 
   2923   <div class="jd-tagdata jd-tagdescr"><p>Take a screenshot of current window and store it as PNG
   2924 
   2925  Default scale of 1.0f (original size) and 90% quality is used
   2926  The screenshot is adjusted per screen rotation</p></div>
   2927   <div class="jd-tagdata">
   2928       <h5 class="jd-tagtitle">Parameters</h5>
   2929       <table class="jd-tagtable">
   2930         <tr>
   2931           <th>storePath</td>
   2932           <td>where the PNG should be written to</td>
   2933         </tr>
   2934       </table>
   2935   </div>
   2936   <div class="jd-tagdata">
   2937       <h5 class="jd-tagtitle">Returns</h5>
   2938       <ul class="nolist"><li>true if screen shot is created successfully, false otherwise</li></ul>
   2939   </div>
   2940   <div class="jd-tagdata">
   2941      <h5 class="jd-tagtitle">Since</h5>
   2942      <ul class="nolist"><li>Android API Level 17</li></ul>
   2943   </div>
   2944     </div>
   2945 </div>
   2946 
   2947 
   2948 <A NAME="takeScreenshot(java.io.File, float, int)"></A>
   2949 
   2950 <div class="jd-details api">
   2951     <h4 class="jd-details-title">
   2952       <span class="normal">
   2953         public
   2954 
   2955 
   2956 
   2957 
   2958         boolean
   2959       </span>
   2960       <span class="sympad">takeScreenshot</span>
   2961       <span class="normal">(File storePath, float scale, int quality)</span>
   2962     </h4>
   2963     <div class="jd-details-descr">
   2964 
   2965   <div class="jd-tagdata jd-tagdescr"><p>Take a screenshot of current window and store it as PNG
   2966 
   2967  The screenshot is adjusted per screen rotation</p></div>
   2968   <div class="jd-tagdata">
   2969       <h5 class="jd-tagtitle">Parameters</h5>
   2970       <table class="jd-tagtable">
   2971         <tr>
   2972           <th>storePath</td>
   2973           <td>where the PNG should be written to</td>
   2974         </tr>
   2975         <tr>
   2976           <th>scale</td>
   2977           <td>scale the screenshot down if needed; 1.0f for original size</td>
   2978         </tr>
   2979         <tr>
   2980           <th>quality</td>
   2981           <td>quality of the PNG compression; range: 0-100</td>
   2982         </tr>
   2983       </table>
   2984   </div>
   2985   <div class="jd-tagdata">
   2986       <h5 class="jd-tagtitle">Returns</h5>
   2987       <ul class="nolist"><li>true if screen shot is created successfully, false otherwise</li></ul>
   2988   </div>
   2989   <div class="jd-tagdata">
   2990      <h5 class="jd-tagtitle">Since</h5>
   2991      <ul class="nolist"><li>Android API Level 17</li></ul>
   2992   </div>
   2993     </div>
   2994 </div>
   2995 
   2996 
   2997 <A NAME="unfreezeRotation()"></A>
   2998 
   2999 <div class="jd-details api">
   3000     <h4 class="jd-details-title">
   3001       <span class="normal">
   3002         public
   3003 
   3004 
   3005 
   3006 
   3007         void
   3008       </span>
   3009       <span class="sympad">unfreezeRotation</span>
   3010       <span class="normal">()</span>
   3011     </h4>
   3012       <div class="api-level">
   3013         <div></div>
   3014 
   3015 
   3016 
   3017       </div>
   3018     <div class="jd-details-descr">
   3019 
   3020   <div class="jd-tagdata jd-tagdescr"><p>Re-enables the sensors and un-freezes the device rotation allowing its contents
   3021  to rotate with the device physical rotation. During a test execution, it is best to
   3022  keep the device frozen in a specific orientation until the test case execution has completed.</p></div>
   3023   <div class="jd-tagdata">
   3024       <h5 class="jd-tagtitle">Throws</h5>
   3025       <table class="jd-tagtable">
   3026         <tr>
   3027             <th>RemoteException</td>
   3028             <td></td>
   3029         </tr>
   3030       </table>
   3031   </div>
   3032 
   3033     </div>
   3034 </div>
   3035 
   3036 
   3037 <A NAME="waitForIdle(long)"></A>
   3038 
   3039 <div class="jd-details api">
   3040     <h4 class="jd-details-title">
   3041       <span class="normal">
   3042         public
   3043 
   3044 
   3045 
   3046 
   3047         void
   3048       </span>
   3049       <span class="sympad">waitForIdle</span>
   3050       <span class="normal">(long timeout)</span>
   3051     </h4>
   3052       <div class="api-level">
   3053         <div></div>
   3054 
   3055 
   3056 
   3057       </div>
   3058     <div class="jd-details-descr">
   3059 
   3060   <div class="jd-tagdata jd-tagdescr"><p>Waits for the current application to idle.</p></div>
   3061   <div class="jd-tagdata">
   3062       <h5 class="jd-tagtitle">Parameters</h5>
   3063       <table class="jd-tagtable">
   3064         <tr>
   3065           <th>timeout</td>
   3066           <td>in milliseconds</td>
   3067         </tr>
   3068       </table>
   3069   </div>
   3070 
   3071     </div>
   3072 </div>
   3073 
   3074 
   3075 <A NAME="waitForIdle()"></A>
   3076 
   3077 <div class="jd-details api">
   3078     <h4 class="jd-details-title">
   3079       <span class="normal">
   3080         public
   3081 
   3082 
   3083 
   3084 
   3085         void
   3086       </span>
   3087       <span class="sympad">waitForIdle</span>
   3088       <span class="normal">()</span>
   3089     </h4>
   3090       <div class="api-level">
   3091         <div></div>
   3092 
   3093 
   3094 
   3095       </div>
   3096     <div class="jd-details-descr">
   3097 
   3098   <div class="jd-tagdata jd-tagdescr"><p>Waits for the current application to idle.
   3099  Default wait timeout is 10 seconds</p></div>
   3100 
   3101     </div>
   3102 </div>
   3103 
   3104 
   3105 <A NAME="waitForWindowUpdate(java.lang.String, long)"></A>
   3106 
   3107 <div class="jd-details api">
   3108     <h4 class="jd-details-title">
   3109       <span class="normal">
   3110         public
   3111 
   3112 
   3113 
   3114 
   3115         boolean
   3116       </span>
   3117       <span class="sympad">waitForWindowUpdate</span>
   3118       <span class="normal">(String packageName, long timeout)</span>
   3119     </h4>
   3120       <div class="api-level">
   3121         <div></div>
   3122 
   3123 
   3124 
   3125       </div>
   3126     <div class="jd-details-descr">
   3127 
   3128   <div class="jd-tagdata jd-tagdescr"><p>Waits for a window content update event to occur.
   3129 
   3130  If a package name for the window is specified, but the current window
   3131  does not have the same package name, the function returns immediately.</p></div>
   3132   <div class="jd-tagdata">
   3133       <h5 class="jd-tagtitle">Parameters</h5>
   3134       <table class="jd-tagtable">
   3135         <tr>
   3136           <th>packageName</td>
   3137           <td>the specified window package name (can be <code>null</code>).
   3138         If <code>null</code>, a window update from any front-end window will end the wait</td>
   3139         </tr>
   3140         <tr>
   3141           <th>timeout</td>
   3142           <td>the timeout for the wait</td>
   3143         </tr>
   3144       </table>
   3145   </div>
   3146   <div class="jd-tagdata">
   3147       <h5 class="jd-tagtitle">Returns</h5>
   3148       <ul class="nolist"><li>true if a window update occurred, false if timeout has elapsed or if the current
   3149          window does not have the specified package name</li></ul>
   3150   </div>
   3151 
   3152     </div>
   3153 </div>
   3154 
   3155 
   3156 <A NAME="wakeUp()"></A>
   3157 
   3158 <div class="jd-details api">
   3159     <h4 class="jd-details-title">
   3160       <span class="normal">
   3161         public
   3162 
   3163 
   3164 
   3165 
   3166         void
   3167       </span>
   3168       <span class="sympad">wakeUp</span>
   3169       <span class="normal">()</span>
   3170     </h4>
   3171       <div class="api-level">
   3172         <div></div>
   3173 
   3174 
   3175 
   3176       </div>
   3177     <div class="jd-details-descr">
   3178 
   3179   <div class="jd-tagdata jd-tagdescr"><p>This method simulates pressing the power button if the screen is OFF else
   3180  it does nothing if the screen is already ON.
   3181 
   3182  If the screen was OFF and it just got turned ON, this method will insert a 500ms delay
   3183  to allow the device time to wake up and accept input.</p></div>
   3184   <div class="jd-tagdata">
   3185       <h5 class="jd-tagtitle">Throws</h5>
   3186       <table class="jd-tagtable">
   3187         <tr>
   3188             <th></td>
   3189             <td>RemoteException</td>
   3190         </tr>
   3191         <tr>
   3192             <th>RemoteException</td>
   3193             <td></td>
   3194         </tr>
   3195       </table>
   3196   </div>
   3197 
   3198     </div>
   3199 
   3200 
   3201 
   3202 
   3203 
   3204 <!-- ========= METHOD DETAIL ======== -->
   3205 
   3206 
   3207 
   3208 
   3209