blob: 34bbba95a8e321b7d93b884ad558dc4dd9fb85f9 [file] [log] [blame]
Joe Malin9a7eab82010-10-18 17:07:45 -07001page.title=MonkeyDevice
2@jd:body
3<style>
4 h4.jd-details-title {background-color: #DEE8F1;}
5</style>
6<p>
7 A monkeyrunner class that represents a device or emulator accessible by the workstation running
8<code><a href="{@docRoot}guide/developing/tools/monkeyrunner_concepts.html">monkeyrunner</a></code>.
9</p>
10<p>
11 This class is used to control an Android device or emulator. The methods send UI events,
12 retrieve information, install and remove applications, and run applications.
13</p>
14<p>
15 You normally do not have to create an instance of <code>MonkeyDevice</code>. Instead, you
16 use
17<code><a href="{@docRoot}guide/developing/tools/MonkeyRunner.html#waitForConnection">
18MonkeyRunner.waitForConnection()</a></code> to create a new object from a connection to a device or
19emulator. For example, instead of
20using:</p>
21<pre>
22newdevice = MonkeyDevice()
23</pre>
24<p>
25 you would use:
26</p>
27<pre>
28newdevice = MonkeyRunner.waitForConnection()
29</pre>
30<h2>Summary</h2>
31 <table id="constants" class="jd-sumtable" style="background-color: white;">
32 <tr>
33 <th colspan="12" style="background-color: #E2E2E2">Constants</th>
34 </tr>
35 <tr class="api" style="background-color: white;">
36 <td class="jd-typecol"><em>string</em></td>
37 <td class="jd-linkcol"><a href="#ACTION_DOWN">DOWN</a></td>
38 <td class="jd-descrcol" width="100%">
39 Use this with the <code>type</code> argument of
40 <code><a href="#press">press()</a></code> or <code><a href="#touch">touch()</a>
41 </code>
42 to send a DOWN event.
43 </td>
44 </tr>
45 <tr class="api" style="background-color: white;">
46 <td class="jd-typecol"><em>string</em></td>
47 <td class="jd-linkcol"><a href="#ACTION_UP">UP</a></td>
48 <td class="jd-descrcol" width="100%">
49 Use this with the <code>type</code> argument of
50 <code><a href="#press">press()</a></code> or <code><a href="#touch">touch()</a>
51 </code>
52 to send an UP event.
53 </td>
54 </tr>
55 <tr class="api" style="background-color: white;">
56 <td class="jd-typecol"><em>string</em></td>
57 <td class="jd-linkcol"><a href="#ACTION_DOWN_AND_UP">DOWN_AND_UP</a></td>
58 <td class="jd-descrcol" width="100%">
59 Use this with the <code>type</code> argument of
60 <code><a href="#press">press()</a></code> or <code><a href="#touch">touch()</a>
61 </code>
62 to send a DOWN event immediately followed by an UP event.
63 </td>
64 </tr>
65 </table>
66<table id="pubmethods" class="jd-sumtable">
67 <tr>
68 <th colspan="12" style="background-color: #E2E2E2">Methods</th>
69 </tr>
70 <tr class="api" >
71 <td class="jd-typecol">
72 <nobr>
73 void
74 </nobr>
75 </td>
76 <td class="jd-linkcol" width="100%">
77 <nobr>
78 <span class="sympad">
79 <a href="#broadcastIntent">broadcastIntent</a>
80 </span>
81 (<em>string</em> uri,
82 <em>string</em> action,
83 <em>string</em> data,
84 <em>string</em> mimetype,
85 <em>iterable</em> categories
86 <em>dictionary</em> extras,
87 <em>component</em> component,
88 <em>iterable</em> flags)
89 </nobr>
90 <div class="jd-descrdiv">
91 Broadcasts an Intent to this device, as if the Intent were coming from an
92 application.
93 </div>
94 </td>
95 </tr>
96 <tr class="api" >
97 <td class="jd-typecol">
98 <nobr>
99 void
100 </nobr>
101 </td>
102 <td class="jd-linkcol" width="100%">
103 <nobr>
104 <span class="sympad">
105 <a href="#drag">drag</a>
106 </span>
107 (<em>tuple</em> start,
108 <em>tuple</em> end,
109 <em>float</em> duration,
110 <em>integer</em> steps)
111 </nobr>
112 <div class="jd-descrdiv">
113 Simulates a drag gesture (touch, hold, and move) on this device's screen.
114 </div>
115 </td>
116 </tr>
117 <tr class="api" >
118 <td class="jd-typecol">
119 <nobr>
120 <em>object</em>
121 </nobr>
122 </td>
123 <td class="jd-linkcol" width="100%">
124 <nobr>
125 <span class="sympad">
126 <a href="#getProperty">getProperty</a>
127 </span>
128 (<em>string</em> key)
129 </nobr>
130 <div class="jd-descrdiv">
131 Given the name of a system environment variable, returns its value for this device.
132 The available variable names are listed in the <a href="#getProperty">
133 detailed description</a> of this method.
134 </div>
135 </td>
136 </tr>
137 <tr class="api" >
138 <td class="jd-typecol">
139 <nobr>
140 <em>object</em>
141 </nobr>
142 </td>
143 <td class="jd-linkcol" width="100%">
144 <nobr>
145 <span class="sympad">
146 <a href="#getSystemProperty">getSystemProperty</a>
147 </span>
148 (<em>string</em> key)
149 </nobr>
150 <div class="jd-descrdiv">
151. The API equivalent of <code>adb shell getprop &lt;key&gt;. This is provided for use
152 by platform developers.
153 </div>
154 </td>
155 </tr>
156 <tr class="api" >
157 <td class="jd-typecol">
158 <nobr>
159 void
160 </nobr>
161 </td>
162 <td class="jd-linkcol" width="100%">
163 <nobr>
164 <span class="sympad">
165 <a href="#installPackage">installPackage</a>
166 </span>
167 (<em>string</em> path)
168 </nobr>
169 <div class="jd-descrdiv">
170 Installs the Android application or test package contained in packageFile onto this
171 device. If the application or test package is already installed, it is replaced.
172 </div>
173 </td>
174 </tr>
175 <tr class="api" >
176 <td class="jd-typecol">
177 <nobr>
178 <em>dictionary</em>
179 </nobr>
180 </td>
181 <td class="jd-linkcol" width="100%">
182 <nobr>
183 <span class="sympad">
184 <a href="#instrument">instrument</a>
185 </span>
186 (<em>string</em> className,
187 <em>dictionary</em> args)
188 </nobr>
189 <div class="jd-descrdiv">
190 Runs the specified component under Android instrumentation, and returns the results
191 in a dictionary whose exact format is dictated by the component being run. The
192 component must already be present on this device.
193 </div>
194 </td>
195 </tr>
196 <tr class="api">
197 <td class="jd-typecol">
198 <nobr>
199 void
200 </nobr>
201 </td>
202 <td class="jd-linkcol" width="100%">
203 <nobr>
204 <span class="sympad">
205 <a href="#press">press</a>
206 </span>
207 (<em>string</em> name,
208 <em>dictionary</em> type)
209 </nobr>
210 <div class="jd-descrdiv">
211 Sends the key event specified by type to the key specified by
212 keycode.
213 </div>
214 </td>
215 </tr>
216 <tr class="api" >
217 <td class="jd-typecol">
218 <nobr>
219 void
220 </nobr>
221 </td>
222 <td class="jd-linkcol" width="100%">
223 <nobr>
224 <span class="sympad">
225 <a href="#reboot">reboot</a>
226 </span>
227 (<em>string</em> into)
228 </nobr>
229 <div class="jd-descrdiv">
230 Reboots this device into the bootloader specified by bootloadType.
231 </div>
232 </td>
233 </tr>
234 <tr class="api" >
235 <td class="jd-typecol">
236 <nobr>
237 void
238 </nobr>
239 </td>
240 <td class="jd-linkcol" width="100%">
241 <nobr>
242 <span class="sympad">
243 <a href="#removePackage">removePackage</a>
244 </span>
245 (<em>string</em> package)
246 </nobr>
247 <div class="jd-descrdiv">
248 Deletes the specified package from this device, including its data and cache.
249 </div>
250 </td>
251 </tr>
252 <tr class="api" >
253 <td class="jd-typecol">
254 <nobr>
255 <em>object</em>
256 </nobr>
257 </td>
258 <td class="jd-linkcol" width="100%">
259 <nobr>
260 <span class="sympad">
261 <a href="#shell">shell</a>
262 </span>
263 (<em>string</em> cmd)
264 </nobr>
265 <div class="jd-descrdiv">
266 Executes an <code>adb</code> shell command and returns the result, if any.
267 </div>
268 </td>
269 </tr>
270 <tr class="api" >
271 <td class="jd-typecol">
272 <nobr>
273 void
274 </nobr>
275 </td>
276 <td class="jd-linkcol" width="100%">
277 <nobr>
278 <span class="sympad">
279 <a href="#startActivity">startActivity</a>
280 </span>
281 (<em>string</em> uri,
282 <em>string</em> action,
283 <em>string</em> data,
284 <em>string</em> mimetype,
285 <em>iterable</em> categories
286 <em>dictionary</em> extras,
287 <em>component</em> component,
288 <em>flags</em>)
289 </nobr>
290 <div class="jd-descrdiv">
291 Starts an Activity on this device by sending an Intent constructed from the
292 supplied arguments.
293 </div>
294 </td>
295 </tr>
296 <tr class="api" >
297 <td class="jd-typecol">
298 <nobr>
299 <code>
300 <a href="{@docRoot}guide/developing/tools/MonkeyImage.html">
301 MonkeyImage
302 </a>
303 </code>
304 </nobr>
305 </td>
306 <td class="jd-linkcol" width="100%">
307 <nobr>
308 <span class="sympad">
309 <a href="#takeSnapshot">takeSnapshot</a>()
310 </span>
311 </nobr>
312 <div class="jd-descrdiv">
313 Captures the entire screen buffer of this device, yielding a
314 <code>
315 <a href="{@docRoot}guide/developing/tools/MonkeyImage.html">
316 MonkeyImage
317 </a>
318 </code> object containing a screen capture of the current display.
319 </div>
320 </td>
321 </tr>
322 <tr class="api" >
323 <td class="jd-typecol">
324 <nobr>
325 void
326 </nobr>
327 </td>
328 <td class="jd-linkcol" width="100%">
329 <nobr>
330 <span class="sympad">
331 <a href="#touch">touch</a>
332 </span>
333 (<em>integer</em> x,
334 <em>integer</em> y,
335 <em>integer</em> type)
336 </nobr>
337 <div class="jd-descrdiv">
338 Sends a touch event specified by type to the screen location specified
339 by x and y.
340 </div>
341 </td>
342 </tr>
343 <tr class="api" >
344 <td class="jd-typecol">
345 <nobr>
346 void
347 </nobr>
348 </td>
349 <td class="jd-linkcol" width="100%">
350 <nobr>
351 <span class="sympad">
352 <a href="#touch">type</a>
353 </span>
354 (<em>string</em> message)
355 </nobr>
356 <div class="jd-descrdiv">
357 Sends the characters contained in message to this device, as if they
358 had been typed on the device's keyboard. This is equivalent to calling
359 <code><a href="#press">press()</a></code> for each keycode in <code>message</code>
360 using the key event type <code><a href="#ACTION_DOWN_AND_UP"></a>DOWN_AND_UP</code>.
361 </div>
362 </td>
363 </tr>
364 <tr class="api" >
365 <td class="jd-typecol">
366 <nobr>
367 void
368 </nobr>
369 </td>
370 <td class="jd-linkcol" width="100%">
371 <nobr>
372 <span class="sympad">
373 <a href="#touch">wake</a>
374 </span>
375 ()
376 </nobr>
377 <div class="jd-descrdiv">
378 Wakes the screen of this device.
379 </div>
380 </td>
381 </tr>
382</table>
383<!-- ========= ENUM CONSTANTS DETAIL ======== -->
384<h2>Constants</h2>
385<A NAME="ACTION_DOWN"></a>
386<div class="jd-details api">
387 <h4 class="jd-details-title">
388 <span class="normal">
389 <em>string</em>
390 </span>
391 DOWN
392 </h4>
393 <div class="jd-details-descr">
394 <div class="jd-tagdata jd-tagdescr">
395 <p>
396 <code><a href="#press">press()</a></code> or
397 <code><a href="#press">touch()</a></code> value.
398 Specifies that a DOWN event type should be sent to the device, corresponding to
399 pressing down on a key or touching the screen.
400 </p>
401 </div>
402 </div>
403</div>
404<A NAME="ACTION_UP"></A>
405<div class="jd-details api">
406 <h4 class="jd-details-title">
407 <span class="normal">
408 <em>string</em>
409 </span>
410 UP
411 </h4>
412 <div class="jd-details-descr">
413 <div class="jd-tagdata jd-tagdescr">
414 <p>
415 <code><a href="#press">press()</a></code> or
416 <code><a href="#press">touch()</a></code> value.
417 Specifies that an UP event type should be sent to the device, corresponding to
418 releasing a key or lifting up from the screen.
419 </p>
420 </div>
421 </div>
422</div>
423<A NAME="ACTION_DOWN_AND_UP"></A>
424
425<div class="jd-details api">
426 <h4 class="jd-details-title">
427 <span class="normal">
428 <em>string</em>
429 </span>
430 DOWN_AND_UP
431 </h4>
432 <div class="jd-details-descr">
433 <div class="jd-tagdata jd-tagdescr">
434 <p>
435 <code><a href="#press">press()</a></code>,
436 <code><a href="#press">touch()</a></code> or
437 <code><a href="#type">type()</a></code> value.
438 Specifies that a DOWN event type followed by an UP event type should be sent to the
439 device, corresponding to typing a key or clicking the screen.
440 </p>
441 </div>
442 </div>
443</div>
444<!-- ========= METHOD DETAIL ======== -->
445<!-- Public methods -->
446<h2>Public Methods</h2>
447<A NAME="broadcastIntent"></A>
448<div class="jd-details api ">
449 <h4 class="jd-details-title">
450 <span class="normal">
451 void
452 </span>
453 <span class="sympad">broadcastIntent</span>
454 <span class="normal">
455 (
456 <em>string</em> uri,
457 <em>string</em> action,
458 <em>string</em> data,
459 <em>string</em> mimetype,
460 <em>iterable</em> categories
461 <em>dictionary</em> extras,
462 <em>component</em> component,
463 <em>iterable</em> flags)
464 </span>
465 </h4>
466 <div class="jd-details-descr">
467
468 <div class="jd-tagdata jd-tagdescr">
469 <p>
470 Broadcasts an Intent to this device, as if the Intent were coming from an
471 application. See {@link android.content.Intent Intent} for more information about the
472 arguments.
473 </p>
474 </div>
475 <div class="jd-tagdata">
476 <h5 class="jd-tagtitle">Arguments</h5>
477 <table class="jd-tagtable">
478 <tr>
479 <th>uri</th>
480 <td>
481 The URI for the Intent.
482 (see {@link android.content.Intent#setData(android.net.Uri) Intent.setData()}).
483 </td>
484 </tr>
485 <tr>
486 <th>action</th>
487 <td>
488 The action for this Intent
489 (see {@link android.content.Intent#setAction(java.lang.String) Intent.setAction()}).
490 </td>
491 </tr>
492 <tr>
493 <th>data</th>
494 <td>
495 The data URI for this Intent
496 (see {@link android.content.Intent#setData(android.net.Uri) Intent.setData()}).
497 </td>
498 </tr>
499 <tr>
500 <th>mimetype</th>
501 <td>
502 The MIME type for the Intent
503 (see {@link android.content.Intent#setType(java.lang.String) Intent.setType()}).
504 </td>
505 </tr>
506 <tr>
507 <th>categories</th>
508 <td>
509 An iterable data structure containing strings that define categories for this
510 Intent
511 (see
512 {@link android.content.Intent#addCategory(java.lang.String) Intent.addCategory()}).
513 </td>
514 </tr>
515 <tr>
516 <th>extras</th>
517 <td>
518 A dictionary of extra data for this Intent
519 (see {@link android.content.Intent#putExtra(java.lang.String,java.lang.String)
520 Intent.putExtra()}
521 for an example).
522 <p>
523 The key for each dictionary item should be a <em>string</em>. The item's value
524 can be any simple or structured data type.
525 </p>
526 </td>
527 </tr>
528 <tr>
529 <th>component</th>
530 <td>
531 The component for this Intent (see {@link android.content.ComponentName}).
532 Using this argument will direct the Intent to a specific class within a specific
533 Android package.
534 </td>
535 </tr>
536 <tr>
537 <th>flags</th>
538 <td>
539 An iterable data structure containing flags that control how the Intent is handled
540 (see {@link android.content.Intent#setFlags(int) Intent.setFlags()}).
541 </td>
542 </tr>
543 </table>
544 </div>
545 </div>
546</div>
547<A NAME="drag"></A>
548<div class="jd-details api ">
549 <h4 class="jd-details-title">
550 <span class="normal">
551 void
552 </span>
553 <span class="sympad">drag</span>
554 <span class="normal">
555 (
556 <em>tuple</em> start,
557 <em>tuple</em> end,
558 <em>float</em> duration,
559 <em>integer</em> steps)
560 </span>
561 </h4>
562 <div class="jd-details-descr">
563
564 <div class="jd-tagdata jd-tagdescr">
565 <p>
566 Simulates a drag gesture (touch, hold, and move) on this device's screen.
567 </p>
568 </div>
569 <div class="jd-tagdata">
570 <h5 class="jd-tagtitle">Arguments</h5>
571 <table class="jd-tagtable">
572 <tr>
573 <th>start</th>
574 <td>
575 The starting point of the drag gesture, in the form of a <em>tuple</em>
576 (x,y) where x and y are <em>integers</em>.
577 </td>
578 </tr>
579 <tr>
580 <th>end</th>
581 <td>
582 The end point of the drag gesture, in the form of a <em>tuple</em> (x,y)
583 where x and y are <em>integers</em>.
584 </td>
585 </tr>
586 <tr>
587 <th>duration</th>
588 <td>The duration of the drag gesture in seconds. The default is 1.0 seconds.</td>
589 </tr>
590 <tr>
591 <th>steps</th>
592 <td>The number of steps to take when interpolating points. The default is 10.</td>
593 </tr>
594 </table>
595 </div>
596 </div>
597</div>
598<A NAME="getProperty"></A>
599<div class="jd-details api ">
600 <h4 class="jd-details-title">
601 <span class="normal">
602 <em>object</em>
603 </span>
604 <span class="sympad">getProperty</span>
605 <span class="normal">
606 (<em>string</em> key)
607 </span>
608 </h4>
609 <div class="jd-details-descr">
610
611 <div class="jd-tagdata jd-tagdescr">
612 <p>
613 Given the name of a system environment variable, returns its value for this device.
614 </p>
615 </div>
616 <div class="jd-tagdata">
617 <h5 class="jd-tagtitle">Arguments</h5>
618 <table class="jd-tagtable">
619 <tr>
620 <th>key</th>
621 <td>
622 The name of the system environment variable. The available variable names are listed in
623 <a href="#table1">Table 1. Property variable names</a> at the end of this topic.
624 </td>
625 </tr>
626 </table>
627 </div>
628 <div class="jd-tagdata">
629 <h5 class="jd-tagtitle">Returns</h5>
630 <ul class="nolist">
631 <li>
632 The value of the variable. The data format varies according to the variable requested.
633 </li>
634 </ul>
635 </div>
636 </div>
637</div>
638<A NAME="getSystemProperty"></A>
639<div class="jd-details api ">
640 <h4 class="jd-details-title">
641 <span class="normal">
642 <em>object</em>
643 </span>
644 <span class="sympad">getSystemProperty</span>
645 <span class="normal">
646 (<em>string</em> key)
647 </span>
648 </h4>
649 <div class="jd-details-descr">
650
651 <div class="jd-tagdata jd-tagdescr">
652 <p>
653 Synonym for <code><a href="#getProperty">getProperty()</a></code>.
654 </p>
655 </div>
656 <div class="jd-tagdata">
657 <h5 class="jd-tagtitle">Arguments</h5>
658 <table class="jd-tagtable">
659 <tr>
660 <th>key</th>
661 <td>
662 The name of the system environment variable. The available variable names are listed in
663 <a href="#table1">Table 1. Property Variable Names</a>.
664 </td>
665 </tr>
666 </table>
667 </div>
668 <div class="jd-tagdata">
669 <h5 class="jd-tagtitle">Returns</h5>
670 <ul class="nolist">
671 <li>
672 The value of the variable. The data format varies according to the variable requested.
673 </li>
674 </ul>
675 </div>
676 </div>
677</div>
678<A NAME="installPackage"></A>
679<div class="jd-details api ">
680 <h4 class="jd-details-title">
681 <span class="normal">
682 void
683 </span>
684 <span class="sympad">installPackage</span>
685 <span class="normal">
686 (<em>string</em> path)
687 </span>
688 </h4>
689 <div class="jd-details-descr">
690
691 <div class="jd-tagdata jd-tagdescr">
692 <p>
693 Installs the Android application or test package contained in packageFile
694 onto this device. If the application or test package is already installed, it is
695 replaced.
696 </p>
697 </div>
698 <div class="jd-tagdata">
699 <h5 class="jd-tagtitle">Arguments</h5>
700 <table class="jd-tagtable">
701 <tr>
702 <th>path</th>
703 <td>
704 The fully-qualified path and filename of the <code>.apk</code> file to install.
705 </td>
706 </tr>
707 </table>
708 </div>
709 </div>
710</div>
711<A NAME="instrument"></A>
712<div class="jd-details api ">
713 <h4 class="jd-details-title">
714 <span class="normal">
715 <em>dictionary</em>
716 </span>
717 <span class="sympad">instrument</span>
718 <span class="normal">
719 (
720 <em>string</em> className,
721 <em>dictionary</em> args)
722 </span>
723 </h4>
724 <div class="jd-details-descr">
725
726 <div class="jd-tagdata jd-tagdescr">
727 <p>
728 Runs the specified component with Android instrumentation, and returns the results
729 in a dictionary whose exact format is dictated by the component being run. The
730 component must already be present on this device.
731 </p>
732 <p>
733 Use this method to start a test case that uses one of Android's test case classes.
734 See <a href="{@docRoot}guide/topics/testing/testing_android.html">Testing
735 Fundamentals</a> to learn more about unit testing with the Android testing
736 framework.
737 </p>
738 </div>
739 <div class="jd-tagdata">
740 <h5 class="jd-tagtitle">Arguments</h5>
741 <table class="jd-tagtable">
742 <tr>
743 <th>className</th>
744 <td>
745 The name of an Android component that is already installed on this device, in the
746 standard form packagename/classname, where packagename is the
747 Android package name of a <code>.apk</code> file on this device, and
748 classname is the class name of an Android component (Activity,
749 ContentProvider, Service, or BroadcastReceiver) in that file. Both
750 packagename and classname must be fully qualified. See
751 {@link android.content.ComponentName} for more details.
752 </td>
753 </tr>
754 <tr>
755 <th>args</th>
756 <td>
757 A dictionary containing flags and their values. These are passed to the component as it
758 is started. If the flag does not take a value, set its dictionary value to an empty
759 string.
760 </td>
761 </tr>
762 </table>
763 <div class="jd-tagdata">
764 <h5 class="jd-tagtitle">Returns</h5>
765 <ul class="nolist">
766 <li>
767 <p>
768 A dictionary containing the component's output. The contents of the dictionary
769 are defined by the component itself.
770 </p>
771 <p>
772 If you use {@link android.test.InstrumentationTestRunner} as the class name in
773 the componentName argument, then the result dictionary contains
774 the single key "stream". The value of "stream" is a <em>string</em> containing
775 the test output, as if <code>InstrumentationTestRunner</code> was run from the
776 command line. The format of this output is described in
777 <a href="{@docRoot}guide/developing/testing/testing_otheride.html">
778 Testing in Other IDEs</a>.
779 </p>
780 </li>
781 </ul>
782 </div>
783 </div>
784 </div>
785</div>
786<A NAME="press"></A>
787<div class="jd-details api ">
788 <h4 class="jd-details-title">
789 <span class="normal">
790 void
791 </span>
792 <span class="sympad">press</span>
793 <span class="normal">
794 (<em>string</em> name,
795 <em>integer</em> type)
796 </span>
797 </h4>
798 <div class="jd-details-descr">
799 <div class="jd-tagdata jd-tagdescr">
800 <p>
801 Sends the key event specified by <code>type</code> to the key specified by
802 <code>keycode</code>.
803 </p>
804 </div>
805 <div class="jd-tagdata">
806 <h5 class="jd-tagtitle">Arguments</h5>
807 <table class="jd-tagtable">
808 <tr>
809 <th>name</th>
810 <td>
811 The name of the keycode to send. See {@link android.view.KeyEvent} for a list of
812 keycode names. Use the keycode name, not its integer value.
813 </td>
814 </tr>
815 <tr>
816 <th>type</th>
817 <td>
818 The type of key event to send. The allowed values are <code><a href="#ACTION_DOWN">
819 DOWN</a></code>, <code><a href="#ACTION_UP">UP</a></code>, and
820 <code><a href="#ACTION_DOWN_AND_UP">DOWN_AND_UP</a></code>.
821 </td>
822 </tr>
823 </table>
824 </div>
825 </div>
826</div>
827<A NAME="reboot"></A>
828<div class="jd-details api ">
829 <h4 class="jd-details-title">
830 <span class="normal">
831 void
832 </span>
833 <span class="sympad">reboot</span>
834 <span class="normal">
835 (<em>string</em> bootloadType)
836 </span>
837 </h4>
838 <div class="jd-details-descr">
839
840 <div class="jd-tagdata jd-tagdescr">
841 <p>
842 Reboots this device into the bootloader specified by <code>bootloadType</code>.
843 </p>
844 </div>
845 <div class="jd-tagdata">
846 <h5 class="jd-tagtitle">Arguments</h5>
847 <table class="jd-tagtable">
848 <tr>
849 <th>into</th>
850 <td>
851 The type of bootloader to reboot into. The allowed values are
852 "bootloader", "recovery", or "None".
853 </td>
854 </tr>
855 </table>
856 </div>
857 </div>
858</div>
859<A NAME="removePackage"></A>
860<div class="jd-details api ">
861 <h4 class="jd-details-title">
862 <span class="normal">
863 void
864 </span>
865 <span class="sympad">removePackage</span>
866 <span class="normal">
867 (<em>string</em> package)
868 </span>
869 </h4>
870 <div class="jd-details-descr">
871
872 <div class="jd-tagdata jd-tagdescr">
873 <p>
874 Deletes the specified package from this device, including its data and cache.
875 </p>
876 </div>
877 <div class="jd-tagdata">
878 <h5 class="jd-tagtitle">Arguments</h5>
879 <table class="jd-tagtable">
880 <tr>
881 <th>package</th>
882 <td>
883 The Android package name of an <code>.apk</code> file on this device.
884 </td>
885 </table>
886 </div>
887 </div>
888</div>
889<A NAME="shell"></A>
890<div class="jd-details api ">
891 <h4 class="jd-details-title">
892 <span class="normal">
893 <em>object</em>
894 </span>
895 <span class="sympad">shell</span>
896 <span class="normal">
897 (<em>string</em> cmd)
898 </span>
899 </h4>
900 <div class="jd-details-descr">
901 <div class="jd-tagdata jd-tagdescr">
902 <p>
903 Executes an <code>adb</code> shell command and returns the result, if any.
904 </p>
905 </div>
906 <div class="jd-tagdata">
907 <h5 class="jd-tagtitle">Arguments</h5>
908 <table class="jd-tagtable">
909 <tr>
910 <th>cmd</th>
911 <td>
912 The command to execute in the <code>adb</code> shell. The form of these commands is
913 described in the topic <a href="{@docRoot}guide/developing/tools/adb.html">Android
914 Debug Bridge</a>.
915 </td>
916 </tr>
917 </table>
918 </div>
919 <div class="jd-tagdata">
920 <h5 class="jd-tagtitle">Returns</h5>
921 <ul class="nolist">
922 <li>
923 The results of the command, if any. The format of the results is determined by the
924 command.
925 </li>
926 </ul>
927 </div>
928 </div>
929</div>
930<A NAME="startActivity"></A>
931<div class="jd-details api ">
932 <h4 class="jd-details-title">
933 <span class="normal">
934 void
935 </span>
936 <span class="sympad">startActivity</span>
937 <span class="normal">
938 (
939 <em>string</em> uri,
940 <em>string</em> action,
941 <em>string</em> data,
942 <em>string</em> mimetype,
943 <em>iterable</em> categories
944 <em>dictionary</em> extras,
945 <em>component</em> component,
946 <em>iterable</em> flags)
947 </span>
948 </h4>
949 <div class="jd-details-descr">
950 <div class="jd-tagdata jd-tagdescr">
951 <p>
952 Starts an Activity on this device by sending an Intent constructed from the
953 supplied arguments.
954 </p>
955 </div>
956 <div class="jd-tagdata">
957 <h5 class="jd-tagtitle">Arguments</h5>
958 <table class="jd-tagtable">
959 <tr>
960 <th>uri</th>
961 <td>
962 The URI for the Intent.
963 (see {@link android.content.Intent#setData(android.net.Uri) Intent.setData()}).
964 </td>
965 </tr>
966 <tr>
967 <th>action</th>
968 <td>
969 The action for the Intent
970 (see {@link android.content.Intent#setAction(java.lang.String) Intent.setAction()}).
971 </td>
972 </tr>
973 <tr>
974 <th>data</th>
975 <td>
976 The data URI for the Intent
977 (see {@link android.content.Intent#setData(android.net.Uri) Intent.setData()}).
978 </td>
979 </tr>
980 <tr>
981 <th>mimetype</th>
982 <td>
983 The MIME type for the Intent
984 (see {@link android.content.Intent#setType(java.lang.String) Intent.setType()}).
985 </td>
986 </tr>
987 <tr>
988 <th>categories</th>
989 <td>
990 An iterable data structure containing strings that define categories for the
991 Intent
992 (see
993 {@link android.content.Intent#addCategory(java.lang.String) Intent.addCategory()}).
994 </td>
995 </tr>
996 <tr>
997 <th>extras</th>
998 <td>
999 A dictionary of extra data for the Intent
1000 (see
1001 {@link android.content.Intent#putExtra(java.lang.String,java.lang.String)
1002 Intent.putExtra()}
1003 for an example).
1004 <p>
1005 The key for each dictionary item should be a <em>string</em>. The item's value
1006 can be any simple or structured data type.
1007 </p>
1008 </td>
1009 </tr>
1010 <tr>
1011 <th>component</th>
1012 <td>
1013 The component for the Intent
1014 (see {@link android.content.ComponentName}). Using this argument will direct the
1015 Intent to a specific class within a specific Android package.
1016 </td>
1017 </tr>
1018 <tr>
1019 <th>flags</th>
1020 <td>
1021 An iterable data structure containing flags that control how the Intent is handled
1022 (see {@link android.content.Intent#setFlags(int) Intent.setFlags()}).
1023 </td>
1024 </tr>
1025 </table>
1026 </div>
1027 </div>
1028</div>
1029<A NAME="takeSnapshot"></A>
1030<div class="jd-details api ">
1031 <h4 class="jd-details-title">
1032 <span class="normal">
1033 <code>
1034 <a href="{@docRoot}guide/developing/tools/MonkeyImage.html">
1035 MonkeyImage
1036 </a>
1037 </code>
1038 </span>
1039 <span class="sympad">takeSnapshot</span>
1040 <span class="normal">
1041 ()
1042 </span>
1043 </h4>
1044 <div class="jd-details-descr">
1045 <div class="jd-tagdata jd-tagdescr">
1046 <p>
1047 Captures the entire screen buffer of this device, yielding a
1048 screen capture of the current display.
1049 </p>
1050 </div>
1051 <div class="jd-tagdata">
1052 <h5 class="jd-tagtitle">Returns</h5>
1053 <ul class="nolist">
1054 <li>
1055 A <a href="{@docRoot}guide/developing/tools/MonkeyImage.html">
1056 MonkeyImage</a> object containing the image of the current display.
1057 </li>
1058 </ul>
1059 </div>
1060 </div>
1061</div>
1062<A NAME="touch"></A>
1063<div class="jd-details api ">
1064 <h4 class="jd-details-title">
1065 <span class="normal">
1066 void
1067 </span>
1068 <span class="sympad">touch</span>
1069 <span class="normal">
1070 (
1071 <em>integer</em> x,
1072 <em>integer</em> y,
1073 <em>string</em> type)
1074 </span>
1075 </h4>
1076 <div class="jd-details-descr">
1077 <div class="jd-tagdata jd-tagdescr">
1078 <p>
1079 Sends a touch event specified by type to the screen location specified
1080 by x and y.
1081 </p>
1082 </div>
1083 <div class="jd-tagdata">
1084 <h5 class="jd-tagtitle">Arguments</h5>
1085 <table class="jd-tagtable">
1086 <tr>
1087 <th>x</th>
1088 <td>
1089 The horizontal position of the touch in actual device pixels, starting from the left of
1090 the screen in its current orientation.
1091 </td>
1092 </tr>
1093 <tr>
1094 <th>y</th>
1095 <td>
1096 The vertical position of the touch in actual device pixels, starting from the top of
1097 the screen in its current orientation.
1098 </td>
1099 </tr>
1100 <tr>
1101 <th>type</th>
1102 <td>
1103 The type of key event to send. The allowed values are <code><a href="#ACTION_DOWN">
1104 DOWN</a></code>, <code><a href="#ACTION_UP">UP</a></code>, and
1105 <code><a href="#ACTION_DOWN_AND_UP">DOWN_AND_UP</a></code>.
1106 </td>
1107 </tr>
1108 </table>
1109 </div>
1110 </div>
1111</div>
1112<A NAME="type"></A>
1113<div class="jd-details api ">
1114 <h4 class="jd-details-title">
1115 <span class="normal">
1116 void
1117 </span>
1118 <span class="sympad">type</span>
1119 <span class="normal">
1120 (<em>string</em> message)
1121 </span>
1122 </h4>
1123 <div class="jd-details-descr">
1124 <div class="jd-tagdata jd-tagdescr">
1125 <p>
1126 Sends the characters contained in message to this device, as if they
1127 had been typed on the device's keyboard. This is equivalent to calling
1128 <code><a href="#press">press()</a></code> for each keycode in <code>message</code>
1129 using the key event type <code><a href="#ACTION_DOWN_AND_UP">DOWN_AND_UP</a></code>.
1130 </p>
1131 </div>
1132 <div class="jd-tagdata">
1133 <h5 class="jd-tagtitle">Arguments</h5>
1134 <table class="jd-tagtable">
1135 <tr>
1136 <th>message</th>
1137 <td>
1138 A string containing the characters to send.
1139 </td>
1140 </tr>
1141 </table>
1142 </div>
1143 </div>
1144</div>
1145<A NAME="wake"></A>
1146<div class="jd-details api">
1147 <h4 class="jd-details-title">
1148 <span class="normal">
1149 void
1150 </span>
1151 <span class="sympad">wake</span>
1152 <span class="normal">
1153 ()
1154 </span>
1155 </h4>
1156 <div class="jd-details-descr">
1157 <div class="jd-tagdata jd-tagdescr">
1158 <p>
1159 Wakes the screen of this device.
1160 </p>
1161 </div>
1162 </div>
1163</div>
1164<hr></hr>
1165<h2>Appendix</h2>
1166 <p class="table-caption" id="table1">
1167 <strong>Table 1.</strong>Property variable names used with
1168 <span class="sympad"><a href="#getProperty">getProperty()</a></span> and
1169 <span class="sympad"><a href="#getSystemProperty">getSystemProperty()</a></span>.
1170 </p>
1171 <table>
1172 <tr>
1173 <th>
1174 Property Group
1175 </th>
1176 <th>
1177 Property
1178 </th>
1179 <th>
1180 Description
1181 </th>
1182 <th>
1183 Notes
1184 </th>
1185 </tr>
1186 <tr>
1187 <td rowspan="17"><code>build</code></td>
1188 <td><code>board</code></td>
1189 <td>Code name for the device's system board</td>
1190 <td rowspan="17">
1191 See {@link android.os.Build}
1192 </td>
1193 </tr>
1194 <tr>
1195 <td><code>brand</code></td>
1196 <td>The carrier or provider for which the OS is customized.</td>
1197 </tr>
1198 <tr>
1199 <td><code>device</code></td>
1200 <td>The device design name.</td>
1201 </tr>
1202 <tr>
1203 <td><code>fingerprint</code></td>
1204 <td>A unique identifier for the currently-running build.</td>
1205 </tr>
1206 <tr>
1207 <td><code>host</code></td>
1208 <td></td>
1209 </tr>
1210 <tr>
1211 <td><code>ID</code></td>
1212 <td>A changelist number or label.</td>
1213 </tr>
1214 <tr>
1215 <td><code>model</code></td>
1216 <td>The end-user-visible name for the device.</td>
1217 </tr>
1218 <tr>
1219 <td><code>product</code></td>
1220 <td>The overall product name.</td>
1221 </tr>
1222 <tr>
1223 <td><code>tags</code></td>
1224 <td>Comma-separated tags that describe the build, such as "unsigned" and "debug".</td>
1225 </tr>
1226 <tr>
1227 <td><code>type</code></td>
1228 <td>The build type, such as "user" or "eng".</td>
1229 </tr>
1230 <tr>
1231 <td><code>user</code></td>
1232 <td></td>
1233 </tr>
1234 <tr>
1235 <td><code>CPU_ABI</code></td>
1236 <td>
1237 The name of the native code instruction set, in the form CPU type plus
1238 ABI convention.
1239 </td>
1240 </tr>
1241 <tr>
1242 <td><code>manufacturer</code></td>
1243 <td>The product/hardware manufacturer.</td>
1244 </tr>
1245 <tr>
1246 <td><code>version.incremental</code></td>
1247 <td>
1248 The internal code used by the source control system to represent this version
1249 of the software.
1250 </td>
1251 </tr>
1252 <tr>
1253 <td><code>version.release</code></td>
1254 <td>The user-visible name of this version of the software.</td>
1255 </tr>
1256 <tr>
1257 <td><code>version.sdk</code></td>
1258 <td>The user-visible SDK version associated with this version of the OS.</td>
1259 </tr>
1260 <tr>
1261 <td><code>version.codename</code></td>
1262 <td>
1263 The current development codename, or "REL" if this version of the software has been
1264 released.
1265 </td>
1266 </tr>
1267 <tr>
1268 <td rowspan="3"><code>display</code></td>
1269 <td><code>width</code></td>
1270 <td>The device's display width in pixels.</td>
1271 <td rowspan="3">
1272 See
1273 {@link android.util.DisplayMetrics} for details.
1274 </td>
1275 </tr>
1276 <tr>
1277 <td><code>height</code></td>
1278 <td>The device's display height in pixels.</td>
1279 </tr>
1280 <tr>
1281 <td><code>density</code></td>
1282 <td>
1283 The logical density of the display. This is a factor that scales
1284 DIP (Density-Independent Pixel) units to the device's resolution. DIP is adjusted so
1285 that 1 DIP is equivalent to one pixel on a 160 pixel-per-inch display. For example,
1286 on a 160-dpi screen, density = 1.0, while on a 120-dpi screen, density = .75.
1287 <p>
1288 The value does not exactly follow the real screen size, but is adjusted to
1289 conform to large changes in the display DPI. See
1290 {@link android.util.DisplayMetrics#density} for more details.
1291 </p>
1292 </td>
1293 </tr>
1294 <tr>
1295 <td rowspan="6"><code>am.current</code></td>
1296 <td><code>package</code></td>
1297 <td>The Android package name of the currently running package.</td>
1298 <td rowspan="6">
1299 The <code>am.current</code> keys return information about the currently-running
1300 Activity.
1301 </td>
1302 </tr>
1303 <tr>
1304 <td><code>action</code></td>
1305 <td>
1306 The current activity's action. This has the same format as the <code>name</code>
1307 attribute of the <code>action</code> element in a package manifest.
1308 </td>
1309 </tr>
1310 <tr>
1311 <td><code>comp.class</code></td>
1312 <td>
1313 The class name of the component that started the current Activity. See
1314 <code><a href="#comppackage">comp.package</a></code> for more details.</td>
1315 </tr>
1316 <tr>
1317 <td><a name="comppackage"><code>comp.package</code></a></td>
1318 <td>
1319 The package name of the component that started the current Activity. A component
1320 is specified by a package name and the name of class that the package contains.
1321 </td>
1322 </tr>
1323 <tr>
1324 <td><code>data</code></td>
1325 <td>The data (if any) contained in the Intent that started the current Activity.</td>
1326 </tr>
1327 <tr>
1328 <td><code>categories</code></td>
1329 <td>The categories specified by the Intent that started the current Activity.</td>
1330 </tr>
1331 <tr>
1332 <td rowspan="3"><code>clock</code></td>
1333 <td><code>realtime</code></td>
1334 <td>
1335 The number of milliseconds since the device rebooted, including deep-sleep
1336 time.
1337 </td>
1338 <td rowspan="3">
1339 See {@link android.os.SystemClock} for more information.
1340 </td>
1341 </tr>
1342 <tr>
1343 <td><code>uptime</code></td>
1344 <td>
1345 The number of milliseconds since the device rebooted, <em>not</em> including
1346 deep-sleep time
1347 </td>
1348 </tr>
1349 <tr>
1350 <td><code>millis</code></td>
1351 <td>current time since the UNIX epoch, in milliseconds.</td>
1352 </tr>
1353 </table>