1 page.title=Common Intents 2 page.tags="IntentFilter" 3 @jd:body 4 5 <div id="qv-wrapper"> 6 <div id="qv"> 7 8 <h2>In this document 9 <a href="#" onclick="hideNestedItems('#tocIntents',this);return false;" class="header-toggle"> 10 <span class="more">show more</span> 11 <span class="less" style="display:none">show less</span></a></h2> 12 13 <ol id="tocIntents" class="hide-nested"> 14 <li><a href="#Clock">Alarm Clock</a> 15 <ol> 16 <li><a href="#CreateAlarm">Create an alarm</a></li> 17 <li><a href="#CreateTimer">Create a timer</a></li> 18 <li><a href="#ShowAlarms">Show all alarms</a></li> 19 </ol> 20 </li> 21 <li><a href="#Calendar">Calendar</a> 22 <ol> 23 <li><a href="#AddEvent">Add a calendar event</a></li> 24 </ol> 25 </li> 26 <li><a href="#Camera">Camera</a> 27 <ol> 28 <li><a href="#ImageCapture">Capture a picture or video and return it</a></li> 29 <li><a href="#CameraStill">Start a camera app in still image mode</a></li> 30 <li><a href="#CameraVideo">Start a camera app in video mode</a></li> 31 </ol> 32 </li> 33 <li><a href="#Contacts">Contacts/People App</a> 34 <ol> 35 <li><a href="#PickContact">Select a contact</a></li> 36 <li><a href="#PickContactDat">Select specific contact data</a></li> 37 <li><a href="#ViewContact">View a contact</a></li> 38 <li><a href="#EditContact">Edit an existing contact</a></li> 39 <li><a href="#InsertContact">Insert a contact</a></li> 40 </ol> 41 </li> 42 <li><a href="#Email">Email</a> 43 <ol> 44 <li><a href="#ComposeEmail">Compose an email with optional attachments</a></li> 45 </ol> 46 </li> 47 <li><a href="#Storage">File Storage</a> 48 <ol> 49 <li><a href="#GetFile">Retrieve a specific type of file</a></li> 50 <li><a href="#OpenFile">Open a specific type of file</a></li> 51 </ol> 52 </li> 53 <li><a href="#Local">Local Actions</a> 54 <ol> 55 <li><a href="#CallCar">Call a car</a></li> 56 </ol> 57 </li> 58 <li><a href="#Maps">Maps</a> 59 <ol> 60 <li><a href="#ViewMap">Show a location on a map</a></li> 61 </ol> 62 </li> 63 <li><a href="#Music">Music or Video</a> 64 <ol> 65 <li><a href="#PlayMedia">Play a media file</a></li> 66 <li><a href="#PlaySearch">Play music based on a search query</a></li> 67 </ol> 68 </li> 69 <li><a href="#NewNote">New Note</a> 70 <ol> 71 <li><a href="#CreateNote">Create a note</a></li> 72 </ol> 73 </li> 74 <li><a href="#Phone">Phone</a> 75 <ol> 76 <li><a href="#DialPhone">Initiate a phone call</a></li> 77 </ol> 78 </li> 79 </li> 80 <li><a href="#Search">Search</a> 81 <ol> 82 <li><a href="#SearchOnApp">Search in a specific app</a></li> 83 <li><a href="#SearchWeb">Perform a web search</a></li> 84 </ol> 85 </li> 86 <li><a href="#Settings">Settings</a> 87 <ol> 88 <li><a href="#OpenSettings">Open a specific section of Settings</a></li> 89 </ol> 90 </li> 91 <li><a href="#Messaging">Text Messaging</a> 92 <ol> 93 <li><a href="#SendMessage">Compose an SMS/MMS message with attachment</a></li> 94 </ol> 95 </li> 96 <li><a href="#Browser">Web Browser</a> 97 <ol> 98 <li><a href="#ViewUrl">Load a web URL</a></li> 99 </ol> 100 </li> 101 <li><a href="#AdbIntents">Verify Intents with the Android Debug Bridge</a></li> 102 <li><a href="#Now">Intents Fired by Google Now</a></li> 103 </ol> 104 105 <h2>See also</h2> 106 <ol> 107 <li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent 108 Filters</a></li> 109 </ol> 110 </div> 111 </div> 112 113 <!-- Google Now box styles --> 114 <style type="text/css"> 115 .now-box { 116 border-color: rgb(204,204,204); 117 border-style: solid; 118 border-width: 1px; 119 float: right; 120 margin: 0px 0px 20px 15px; 121 padding: 17px; 122 width: 200px; 123 } 124 .now-box li { 125 font-size: 13px; 126 font-style: italic; 127 margin-top: 0px; 128 } 129 .now-box ul { 130 margin-bottom: 0px; 131 } 132 .now-img { 133 width: 30px; 134 margin-bottom: 0px !important; 135 } 136 .now-img-cont { 137 float: left; 138 margin-right: 10px; 139 } 140 .now-title { 141 font-weight: bold; 142 margin-top: 7px; 143 } 144 .now-list { 145 font-size: 13px; 146 margin-bottom: 10px !important; 147 list-style-type: none; 148 } 149 .now-list li { 150 font-style: italic; 151 } 152 </style> 153 154 <p>An intent allows you to start an activity in another app by describing a simple 155 action you'd like to perform (such as "view a map" or "take a picture") 156 in an {@link android.content.Intent} object. This type of intent is 157 called an <em>implicit</em> intent because it does not specify the app component 158 to start, but instead specifies an <em>action</em> and provides some 159 <em>data</em> with which to perform the action.</p> 160 161 <p>When you call 162 {@link android.content.Context#startActivity startActivity()} or 163 {@link android.app.Activity#startActivityForResult startActivityForResult()} and pass it an 164 implicit intent, the system <a href="{@docRoot}guide/components/intents-filters.html#Resolution" 165 >resolves the intent</a> to an app that can handle the intent 166 and starts its corresponding {@link android.app.Activity}. If there's more than one app 167 that can handle the intent, the system presents the user with a dialog to pick which app 168 to use.</p> 169 170 <p>This page describes several implicit intents that you can use to perform common actions, 171 organized by the type of app that handles the intent. Each section also shows how you can 172 create an <a href="{@docRoot}guide/components/intents-filters.html#Receiving">intent filter</a> to 173 advertise your app's ability to perform the same action.</p> 174 175 <p class="caution"><strong>Caution:</strong> If there are no apps on the device that can receive 176 the implicit intent, your app will crash when it calls {@link android.content.Context#startActivity 177 startActivity()}. To first verify that an app exists to receive the intent, call {@link 178 android.content.Intent#resolveActivity resolveActivity()} on your {@link android.content.Intent} 179 object. If the result is non-null, there is at least one app that can handle the intent and 180 it's safe to call {@link android.content.Context#startActivity startActivity()}. If the result is 181 null, you should not use the intent and, if possible, you should disable the feature that invokes 182 the intent.</p> 183 184 <p>If you're not familiar with how to create intents or intent filters, you should first read 185 <a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>.</p> 186 187 <p>To learn how to fire the intents listed on this page from your development host, see 188 <a href="#AdbIntents">Verify Intents with the Android Debug Bridge</a>.</p> 189 190 <h4>Google Now</h4> 191 192 <p><a href="http://www.google.com/landing/now/">Google Now</a> fires some of the intents listed 193 on this page in response to voice commands. For more information, see 194 <a href="#Now">Intents Fired by Google Now</a>.</p> 195 196 197 198 199 200 201 <h2 id="Clock">Alarm Clock</h2> 202 203 204 <h3 id="CreateAlarm">Create an alarm</h3> 205 206 <!-- Google Now box --> 207 <div class="now-box"> 208 <div class="now-img-cont"> 209 <a href="#Now"> 210 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" width="30" 211 height="30" alt=""/> 212 </a> 213 </div> 214 <p class="now-title">Google Now</p> 215 <ul> 216 <li>"set an alarm for 7 am"</li> 217 </ul> 218 </div> 219 220 <p>To create a new alarm, use the {@link android.provider.AlarmClock#ACTION_SET_ALARM} 221 action and specify alarm details such as the time and message using extras defined below.</p> 222 223 <p class="note"><strong>Note:</strong> Only the hour, minutes, and message extras are available 224 in Android 2.3 (API level 9) and higher. The other extras were added in later versions of the 225 platform.</p> 226 227 <dl> 228 <dt><b>Action</b></dt> 229 <dd>{@link android.provider.AlarmClock#ACTION_SET_ALARM}</dd> 230 231 <dt><b>Data URI</b></dt> 232 <dd>None</dd> 233 234 <dt><b>MIME Type</b></dt> 235 <dd>None 236 </dd> 237 238 <dt><b>Extras</b></dt> 239 <dd> 240 <dl> 241 <dt>{@link android.provider.AlarmClock#EXTRA_HOUR}</dt> 242 <dd>The hour for the alarm.</dd> 243 <dt>{@link android.provider.AlarmClock#EXTRA_MINUTES}</dt> 244 <dd>The minutes for the alarm.</dd> 245 <dt>{@link android.provider.AlarmClock#EXTRA_MESSAGE}</dt> 246 <dd>A custom message to identify the alarm.</dd> 247 <dt>{@link android.provider.AlarmClock#EXTRA_DAYS}</dt> 248 <dd>An {@link java.util.ArrayList} including each week day on which this alarm should 249 be repeated. Each day must be declared with an integer from the {@link java.util.Calendar} 250 class such as {@link java.util.Calendar#MONDAY}. 251 <p>For a one-time alarm, do not specify this extra.</dd> 252 <dt>{@link android.provider.AlarmClock#EXTRA_RINGTONE}</dt> 253 <dd>A {@code content:} URI specifying a ringtone to use with the alarm, or {@link 254 android.provider.AlarmClock#VALUE_RINGTONE_SILENT} for no ringtone. 255 <p>To use the default ringtone, do not specify this extra.</dd> 256 <dt>{@link android.provider.AlarmClock#EXTRA_VIBRATE}</dt> 257 <dd>A boolean specifying whether to vibrate for this alarm.</dd> 258 <dt>{@link android.provider.AlarmClock#EXTRA_SKIP_UI}</dt> 259 <dd>A boolean specifying whether the responding app should skip its UI when setting the alarm. 260 If true, the app should bypass any confirmation UI and simply set the specified alarm.</dd> 261 </dl> 262 </dd> 263 264 265 </dl> 266 267 <p><b>Example intent:</b></p> 268 <pre> 269 public void createAlarm(String message, int hour, int minutes) { 270 Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM) 271 .putExtra(AlarmClock.EXTRA_MESSAGE, message) 272 .putExtra(AlarmClock.EXTRA_HOUR, hour) 273 .putExtra(AlarmClock.EXTRA_MINUTES, minutes); 274 if (intent.resolveActivity(getPackageManager()) != null) { 275 startActivity(intent); 276 } 277 } 278 </pre> 279 280 <div class="note"><strong>Note:</strong> 281 <p>In order to invoke the {@link 282 android.provider.AlarmClock#ACTION_SET_ALARM} intent, your app must have the 283 {@link android.Manifest.permission#SET_ALARM} permission:</p> 284 <pre> 285 <uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> 286 </pre> 287 </div> 288 289 290 <p><b>Example intent filter:</b></p> 291 <pre> 292 <activity ...> 293 <intent-filter> 294 <action android:name="android.intent.action.SET_ALARM" /> 295 <category android:name="android.intent.category.DEFAULT" /> 296 </intent-filter> 297 </activity> 298 </pre> 299 300 301 302 <h3 id="CreateTimer">Create a timer</h3> 303 304 <!-- Google Now box --> 305 <div class="now-box"> 306 <div class="now-img-cont"> 307 <a href="#Now"> 308 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 309 width="30" height="30" alt=""/> 310 </a> 311 </div> 312 <p class="now-title">Google Now</p> 313 <ul> 314 <li>"set timer for 5 minutes"</li> 315 </ul> 316 </div> 317 318 <p>To create a countdown timer, use the {@link android.provider.AlarmClock#ACTION_SET_TIMER} 319 action and specify timer details such as the duration using extras defined below.</p> 320 321 <p class="note"><strong>Note:</strong> This intent was added 322 in Android 4.4 (API level 19).</p> 323 324 <dl> 325 <dt><b>Action</b></dt> 326 <dd>{@link android.provider.AlarmClock#ACTION_SET_TIMER}</dd> 327 328 <dt><b>Data URI</b></dt> 329 <dd>None</dd> 330 331 <dt><b>MIME Type</b></dt> 332 <dd>None 333 </dd> 334 335 <dt><b>Extras</b></dt> 336 <dd> 337 <dl> 338 <dt>{@link android.provider.AlarmClock#EXTRA_LENGTH}</dt> 339 <dd>The length of the timer in seconds.</dd> 340 <dt>{@link android.provider.AlarmClock#EXTRA_MESSAGE}</dt> 341 <dd>A custom message to identify the timer.</dd> 342 <dt>{@link android.provider.AlarmClock#EXTRA_SKIP_UI}</dt> 343 <dd>A boolean specifying whether the responding app should skip its UI when setting the timer. 344 If true, the app should bypass any confirmation UI and simply start the specified timer.</dd> 345 </dl> 346 </dd> 347 348 349 </dl> 350 351 <p><b>Example intent:</b></p> 352 <pre> 353 public void startTimer(String message, int seconds) { 354 Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER) 355 .putExtra(AlarmClock.EXTRA_MESSAGE, message) 356 .putExtra(AlarmClock.EXTRA_LENGTH, seconds) 357 .putExtra(AlarmClock.EXTRA_SKIP_UI, true); 358 if (intent.resolveActivity(getPackageManager()) != null) { 359 startActivity(intent); 360 } 361 } 362 </pre> 363 364 <div class="note"><strong>Note:</strong> 365 <p>In order to invoke the {@link 366 android.provider.AlarmClock#ACTION_SET_TIMER} intent, your app must have the 367 {@link android.Manifest.permission#SET_ALARM} permission:</p> 368 <pre> 369 <uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> 370 </pre> 371 </div> 372 373 374 <p><b>Example intent filter:</b></p> 375 <pre> 376 <activity ...> 377 <intent-filter> 378 <action android:name="android.intent.action.SET_TIMER" /> 379 <category android:name="android.intent.category.DEFAULT" /> 380 </intent-filter> 381 </activity> 382 </pre> 383 384 385 386 387 388 <h3 id="ShowAlarms">Show all alarms</h3> 389 390 <p>To show the list of alarms, use the {@link android.provider.AlarmClock#ACTION_SHOW_ALARMS} 391 action.</p> 392 393 <p>Although not many apps will invoke this intent (it's primarily used by system apps), 394 any app that behaves as an alarm clock should implement 395 this intent filter and respond by showing the list of current alarms.</p> 396 397 <p class="note"><strong>Note:</strong> This intent was added 398 in Android 4.4 (API level 19).</p> 399 400 <dl> 401 <dt><b>Action</b></dt> 402 <dd>{@link android.provider.AlarmClock#ACTION_SHOW_ALARMS}</dd> 403 404 <dt><b>Data URI</b></dt> 405 <dd>None</dd> 406 407 <dt><b>MIME Type</b></dt> 408 <dd>None 409 </dd> 410 </dl> 411 412 <p><b>Example intent filter:</b></p> 413 <pre> 414 <activity ...> 415 <intent-filter> 416 <action android:name="android.intent.action.SHOW_ALARMS" /> 417 <category android:name="android.intent.category.DEFAULT" /> 418 </intent-filter> 419 </activity> 420 </pre> 421 422 423 424 425 426 427 <h2 id="Calendar">Calendar</h2> 428 429 430 <h3 id="AddEvent">Add a calendar event</h3> 431 432 <p>To add a new event to the user's calendar, use the {@link android.content.Intent#ACTION_INSERT} 433 action and specify the data URI with {@link android.provider.CalendarContract.Events#CONTENT_URI 434 Events.CONTENT_URI}. You can then specify various event details using extras defined below.</p> 435 436 <dl> 437 <dt><b>Action</b></dt> 438 <dd>{@link android.content.Intent#ACTION_INSERT}</dd> 439 440 <dt><b>Data URI</b></dt> 441 <dd>{@link android.provider.CalendarContract.Events#CONTENT_URI 442 Events.CONTENT_URI}</dd> 443 444 <dt><b>MIME Type</b></dt> 445 <dd>{@code "vnd.android.cursor.dir/event"} 446 </dd> 447 448 <dt><b>Extras</b></dt> 449 <dd> 450 <dl> 451 <dt>{@link android.provider.CalendarContract#EXTRA_EVENT_ALL_DAY}</dt> 452 <dd>A boolean specifying whether this is an all-day event.</dd> 453 <dt>{@link android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME}</dt> 454 <dd>The start time of the event (milliseconds since epoch).</dd> 455 <dt>{@link android.provider.CalendarContract#EXTRA_EVENT_END_TIME}</dt> 456 <dd>The end time of the event (milliseconds since epoch).</dd> 457 <dt>{@link android.provider.CalendarContract.EventsColumns#TITLE}</dt> 458 <dd>The event title.</dd> 459 <dt>{@link android.provider.CalendarContract.EventsColumns#DESCRIPTION}</dt> 460 <dd>The event description.</dd> 461 <dt>{@link android.provider.CalendarContract.EventsColumns#EVENT_LOCATION}</dt> 462 <dd>The event location.</dd> 463 <dt>{@link android.content.Intent#EXTRA_EMAIL}</dt> 464 <dd>A comma-separated list of email addresses that specify the invitees.</dd> 465 </dl> 466 <p>Many more event details can be specified using the constants defined in the 467 {@link android.provider.CalendarContract.EventsColumns} class.</p> 468 </dd> 469 470 471 </dl> 472 473 <p><b>Example intent:</b></p> 474 <pre> 475 public void addEvent(String title, String location, Calendar begin, Calendar end) { 476 Intent intent = new Intent(Intent.ACTION_INSERT) 477 .setData(Events.CONTENT_URI) 478 .putExtra(Events.TITLE, title) 479 .putExtra(Events.EVENT_LOCATION, location) 480 .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin) 481 .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end); 482 if (intent.resolveActivity(getPackageManager()) != null) { 483 startActivity(intent); 484 } 485 } 486 </pre> 487 488 489 <p><b>Example intent filter:</b></p> 490 <pre> 491 <activity ...> 492 <intent-filter> 493 <action android:name="android.intent.action.INSERT" /> 494 <data android:mimeType="vnd.android.cursor.dir/event" /> 495 <category android:name="android.intent.category.DEFAULT" /> 496 </intent-filter> 497 </activity> 498 </pre> 499 500 501 502 503 504 505 506 507 508 509 510 511 512 <h2 id="Camera">Camera</h2> 513 514 515 516 <h3 id="ImageCapture">Capture a picture or video and return it</h3> 517 518 <p>To open a camera app and receive the resulting photo or video, use the {@link 519 android.provider.MediaStore#ACTION_IMAGE_CAPTURE} or {@link 520 android.provider.MediaStore#ACTION_VIDEO_CAPTURE} action. Also specify the URI location where you'd 521 like the camera to save the photo or video, in the {@link android.provider.MediaStore#EXTRA_OUTPUT} 522 extra.</p> 523 524 525 <dl> 526 <dt><b>Action</b></dt> 527 <dd>{@link android.provider.MediaStore#ACTION_IMAGE_CAPTURE} or<br> 528 {@link android.provider.MediaStore#ACTION_VIDEO_CAPTURE}</dd> 529 530 <dt><b>Data URI Scheme</b></dt> 531 <dd>None</dd> 532 533 <dt><b>MIME Type</b></dt> 534 <dd>None</dd> 535 536 <dt><b>Extras</b></dt> 537 <dd> 538 <dl> 539 <dt>{@link android.provider.MediaStore#EXTRA_OUTPUT}</dt> 540 <dd>The URI location where the camera app should save the photo or 541 video file (as a {@link android.net.Uri} object).</dd> 542 </dl> 543 </dd> 544 </dl> 545 546 <p>When the camera app successfully returns 547 focus to your activity (your app receives the {@link android.app.Activity#onActivityResult 548 onActivityResult()} callback), you can access the photo or video at the URI you specified 549 with the {@link android.provider.MediaStore#EXTRA_OUTPUT} value.</p> 550 551 <p class="note"><strong>Note:</strong> When you use {@link 552 android.provider.MediaStore#ACTION_IMAGE_CAPTURE} to capture a photo, the camera may also return a 553 downscaled copy (a thumbnail) of the photo in the result {@link 554 android.content.Intent}, saved as a {@link android.graphics.Bitmap} in an extra field named 555 <code>"data"</code>.</p> 556 557 558 <p><b>Example intent:</b></p> 559 <pre> 560 static final int REQUEST_IMAGE_CAPTURE = 1; 561 static final Uri mLocationForPhotos; 562 563 public void capturePhoto(String targetFilename) { 564 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 565 intent.putExtra(MediaStore.EXTRA_OUTPUT, 566 Uri.withAppendedPath(mLocationForPhotos, targetFilename)); 567 if (intent.resolveActivity(getPackageManager()) != null) { 568 startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); 569 } 570 } 571 572 @Override 573 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 574 if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { 575 Bitmap thumbnail = data.getParcelable("data"); 576 // Do other work with full size photo saved in mLocationForPhotos 577 ... 578 } 579 } 580 </pre> 581 582 <p>For more information about how to use this intent to capture a photo, including 583 how to create an appropriate {@link android.net.Uri} for the output location, read 584 <a href="{@docRoot}training/camera/photobasics.html">Taking Photos Simply</a> or 585 <a href="{@docRoot}training/camera/videobasics.html">Taking Videos Simply</a>.</p> 586 587 <p><b>Example intent filter:</b></p> 588 <pre> 589 <activity ...> 590 <intent-filter> 591 <action android:name="android.media.action.IMAGE_CAPTURE" /> 592 <category android:name="android.intent.category.DEFAULT" /> 593 </intent-filter> 594 </activity> 595 </pre> 596 597 <p>When handling this intent, your activity should check for the {@link 598 android.provider.MediaStore#EXTRA_OUTPUT} extra in the incoming {@link android.content.Intent}, 599 then save the captured image or video at the location specified by that extra and call {@link 600 android.app.Activity#setResult(int,Intent) setResult()} with an 601 {@link android.content.Intent} that includes a compressed thumbnail 602 in an extra named <code>"data"</code>.</p> 603 604 605 606 <h3 id="CameraStill">Start a camera app in still image mode</h3> 607 608 <!-- Google Now box --> 609 <div class="now-box"> 610 <div class="now-img-cont"> 611 <a href="#Now"> 612 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 613 width="30" height="30" alt=""/> 614 </a> 615 </div> 616 <p class="now-title">Google Now</p> 617 <ul> 618 <li>"take a picture"</li> 619 </ul> 620 </div> 621 622 <p>To open a camera app in still image mode, use the {@link 623 android.provider.MediaStore#INTENT_ACTION_STILL_IMAGE_CAMERA} action.</p> 624 625 <dl> 626 <dt><b>Action</b></dt> 627 <dd>{@link android.provider.MediaStore#INTENT_ACTION_STILL_IMAGE_CAMERA}</dd> 628 629 <dt><b>Data URI Scheme</b></dt> 630 <dd>None</dd> 631 632 <dt><b>MIME Type</b></dt> 633 <dd>None</dd> 634 635 <dt><b>Extras</b></dt> 636 <dd>None</dd> 637 </dl> 638 639 640 <p><b>Example intent:</b></p> 641 <pre> 642 public void capturePhoto() { 643 Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); 644 if (intent.resolveActivity(getPackageManager()) != null) { 645 startActivityForResult(intent); 646 } 647 } 648 </pre> 649 650 <p><b>Example intent filter:</b></p> 651 <pre> 652 <activity ...> 653 <intent-filter> 654 <action android:name="android.media.action.STILL_IMAGE_CAMERA" /> 655 <category android:name="android.intent.category.DEFAULT" /> 656 </intent-filter> 657 </activity> 658 </pre> 659 660 661 662 <h3 id="CameraVideo">Start a camera app in video mode</h3> 663 664 <!-- Google Now box --> 665 <div class="now-box"> 666 <div class="now-img-cont"> 667 <a href="#Now"> 668 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 669 width="30" height="30" alt=""/> 670 </a> 671 </div> 672 <p class="now-title">Google Now</p> 673 <ul> 674 <li>"record a video"</li> 675 </ul> 676 </div> 677 678 <p>To open a camera app in video mode, use the {@link 679 android.provider.MediaStore#INTENT_ACTION_VIDEO_CAMERA} action.</p> 680 681 <dl> 682 <dt><b>Action</b></dt> 683 <dd>{@link android.provider.MediaStore#INTENT_ACTION_VIDEO_CAMERA}</dd> 684 685 <dt><b>Data URI Scheme</b></dt> 686 <dd>None</dd> 687 688 <dt><b>MIME Type</b></dt> 689 <dd>None</dd> 690 691 <dt><b>Extras</b></dt> 692 <dd>None</dd> 693 </dl> 694 695 696 <p><b>Example intent:</b></p> 697 <pre> 698 public void capturePhoto() { 699 Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA); 700 if (intent.resolveActivity(getPackageManager()) != null) { 701 startActivityForResult(intent); 702 } 703 } 704 </pre> 705 706 <p><b>Example intent filter:</b></p> 707 <pre> 708 <activity ...> 709 <intent-filter> 710 <action android:name="android.media.action.VIDEO_CAMERA" /> 711 <category android:name="android.intent.category.DEFAULT" /> 712 </intent-filter> 713 </activity> 714 </pre> 715 716 717 718 719 720 <h2 id="Contacts">Contacts/People App</h2> 721 722 723 <h3 id="PickContact">Select a contact</h3> 724 725 <p>To have the user select a contact and provide your app access to all the contact information, 726 use the {@link android.content.Intent#ACTION_PICK} action and specify the MIME type to 727 {@link android.provider.ContactsContract.Contacts#CONTENT_TYPE 728 Contacts.CONTENT_TYPE}.</p> 729 730 <p>The result {@link android.content.Intent} delivered to your {@link 731 android.app.Activity#onActivityResult onActivityResult()} callback contains the 732 <code>content:</code> URI pointing to the selected contact. The response grants 733 your app temporary permissions to read that contact using the <a 734 href="{@docRoot}guide/topics/providers/contacts-provider.html">Contacts Provider</a> API even if 735 your app does not include the {@link android.Manifest.permission#READ_CONTACTS} permission.</p> 736 737 <p class="note"><strong>Tip:</strong> If you need access to only a specific piece of contact 738 information, such as a phone number or email address, instead see the next section about how to 739 <a href="#PickContactData">select specific contact data</a>.</p> 740 741 <dl> 742 <dt><b>Action</b></dt> 743 <dd>{@link android.content.Intent#ACTION_PICK}</dd> 744 745 <dt><b>Data URI Scheme</b></dt> 746 <dd>None</dd> 747 748 <dt><b>MIME Type</b></dt> 749 <dd>{@link android.provider.ContactsContract.Contacts#CONTENT_TYPE 750 Contacts.CONTENT_TYPE} 751 </dd> 752 </dl> 753 754 <p><b>Example intent:</b></p> 755 <pre> 756 static final int REQUEST_SELECT_CONTACT = 1; 757 758 public void selectContact() { 759 Intent intent = new Intent(Intent.ACTION_PICK); 760 intent.setType(ContactsContract.Contacts.CONTENT_TYPE); 761 if (intent.resolveActivity(getPackageManager()) != null) { 762 startActivityForResult(intent, REQUEST_SELECT_CONTACT); 763 } 764 } 765 766 @Override 767 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 768 if (requestCode == REQUEST_SELECT_CONTACT && resultCode == RESULT_OK) { 769 Uri contactUri = data.getData(); 770 // Do something with the selected contact at contactUri 771 ... 772 } 773 } 774 </pre> 775 776 <p>For information about how to retrieve contact details once you have the contact URI, 777 read <a href="{@docRoot}training/contacts-provider/retrieve-details.html">Retrieving Details 778 for a Contact</a>. Remember, when you retrieve the contact URI with the above intent, you 779 <strong>do not</strong> need the {@link android.Manifest.permission#READ_CONTACTS} permission 780 to read details for that contact.</p> 781 782 783 784 785 <h3 id="PickContactDat">Select specific contact data</h3> 786 787 <p>To have the user select a specific piece of information from a contact, such as 788 a phone number, email address, or other data type, use the 789 {@link android.content.Intent#ACTION_PICK} action and specify the MIME type to one 790 of the content types listed below, such as 791 {@link android.provider.ContactsContract.CommonDataKinds.Phone#CONTENT_TYPE 792 CommonDataKinds.Phone.CONTENT_TYPE} to get the contact's phone number.</p> 793 794 <p>If you need to retrieve only one type of data from a contact, this technique with a 795 {@code CONTENT_TYPE} from the 796 {@link android.provider.ContactsContract.CommonDataKinds} classes is more efficient than 797 using the {@link android.provider.ContactsContract.Contacts#CONTENT_TYPE 798 Contacts.CONTENT_TYPE} (as shown in the previous section) because the result provides you direct 799 access to the desired data without requiring you to perform a more complex query to <a 800 href="{@docRoot}guide/topics/providers/contacts-provider.html">Contacts Provider</a>.</p> 801 802 <p>The result {@link android.content.Intent} delivered to your {@link 803 android.app.Activity#onActivityResult onActivityResult()} callback contains the 804 <code>content:</code> URI pointing to the selected contact data. The response grants 805 your app temporary permissions to read that contact data even if your app does 806 not include the {@link android.Manifest.permission#READ_CONTACTS} permission.</p> 807 808 <dl> 809 <dt><b>Action</b></dt> 810 <dd>{@link android.content.Intent#ACTION_PICK}</dd> 811 812 <dt><b>Data URI Scheme</b></dt> 813 <dd>None</dd> 814 815 <dt><b>MIME Type</b></dt> 816 <dd> 817 <dl> 818 <dt>{@link android.provider.ContactsContract.CommonDataKinds.Phone#CONTENT_TYPE 819 CommonDataKinds.Phone.CONTENT_TYPE}</dt> 820 <dd>Pick from contacts with a phone number.</dd> 821 <dt>{@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_TYPE 822 CommonDataKinds.Email.CONTENT_TYPE}</dt> 823 <dd>Pick from contacts with an email address.</dd> 824 <dt>{@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#CONTENT_TYPE 825 CommonDataKinds.StructuredPostal.CONTENT_TYPE}</dt> 826 <dd>Pick from contacts with a postal address.</dd> 827 </dl> 828 <p>Or one of many other {@code CONTENT_TYPE} values 829 under {@link android.provider.ContactsContract}.</p> 830 </dd> 831 </dl> 832 833 <p><b>Example intent:</b></p> 834 <pre> 835 static final int REQUEST_SELECT_PHONE_NUMBER = 1; 836 837 public void selectContact() { 838 // Start an activity for the user to pick a phone number from contacts 839 Intent intent = new Intent(Intent.ACTION_PICK); 840 intent.setType(CommonDataKinds.Phone.CONTENT_TYPE); 841 if (intent.resolveActivity(getPackageManager()) != null) { 842 startActivityForResult(intent, REQUEST_SELECT_PHONE_NUMBER); 843 } 844 } 845 846 @Override 847 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 848 if (requestCode == REQUEST_SELECT_PHONE_NUMBER && resultCode == RESULT_OK) { 849 // Get the URI and query the content provider for the phone number 850 Uri contactUri = data.getData(); 851 String[] projection = new String[]{CommonDataKinds.Phone.NUMBER}; 852 Cursor cursor = getContentResolver().query(contactUri, projection, 853 null, null, null); 854 // If the cursor returned is valid, get the phone number 855 if (cursor != null && cursor.moveToFirst()) { 856 int numberIndex = cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER); 857 String number = cursor.getString(numberIndex); 858 // Do something with the phone number 859 ... 860 } 861 } 862 } 863 </pre> 864 865 866 867 868 869 <h3 id="ViewContact">View a contact</h3> 870 871 <p>To display the details for a known contact, use the {@link android.content.Intent#ACTION_VIEW} 872 action and specify the contact with a {@code content:} URI as the intent data.</p> 873 874 <p>There are primarily two ways to initially retrieve the contact's URI:</p> 875 <ul> 876 <li>Use the contact URI returned by the {@link android.content.Intent#ACTION_PICK}, 877 shown in the previous section (this approach does not require any app permissions).</li> 878 <li>Access the list of all contacts directly, as described in <a 879 href="{@docRoot}training/contacts-provider/retrieve-names.html">Retrieving a List of 880 Contacts</a> (this approach requires the {@link android.Manifest.permission#READ_CONTACTS} 881 permission).</li> 882 </ul> 883 884 <dl> 885 <dt><b>Action</b></dt> 886 <dd>{@link android.content.Intent#ACTION_VIEW}</dd> 887 888 <dt><b>Data URI Scheme</b></dt> 889 <dd>{@code content:<URI>}</dd> 890 891 <dt><b>MIME Type</b></dt> 892 <dd>None. The type is inferred from contact URI. 893 </dd> 894 </dl> 895 896 <p><b>Example intent:</b></p> 897 <pre> 898 public void viewContact(Uri contactUri) { 899 Intent intent = new Intent(Intent.ACTION_VIEW, contactUri); 900 if (intent.resolveActivity(getPackageManager()) != null) { 901 startActivity(intent); 902 } 903 } 904 </pre> 905 906 907 908 <h3 id="EditContact">Edit an existing contact</h3> 909 910 <p>To edit a known contact, use the {@link android.content.Intent#ACTION_EDIT} 911 action, specify the contact with a {@code content:} URI 912 as the intent data, and include any known contact information in extras specified by 913 constants in {@link android.provider.ContactsContract.Intents.Insert}.</p> 914 915 <p>There are primarily two ways to initially retrieve the contact URI:</p> 916 <ul> 917 <li>Use the contact URI returned by the {@link android.content.Intent#ACTION_PICK}, 918 shown in the previous section (this approach does not require any app permissions).</li> 919 <li>Access the list of all contacts directly, as described in <a 920 href="{@docRoot}training/contacts-provider/retrieve-names.html">Retrieving a List of 921 Contacts</a> (this approach requires the {@link android.Manifest.permission#READ_CONTACTS} 922 permission).</li> 923 </ul> 924 925 <dl> 926 <dt><b>Action</b></dt> 927 <dd>{@link android.content.Intent#ACTION_EDIT}</dd> 928 929 <dt><b>Data URI Scheme</b></dt> 930 <dd>{@code content:<URI>}</dd> 931 932 <dt><b>MIME Type</b></dt> 933 <dd>The type is inferred from contact URI. 934 </dd> 935 936 <dt><b>Extras</b></dt> 937 <dd>One or more of the extras defined in {@link android.provider.ContactsContract.Intents.Insert} 938 so you can populate fields of the contact details. 939 </dd> 940 </dl> 941 942 <p><b>Example intent:</b></p> 943 <pre> 944 public void editContact(Uri contactUri, String email) { 945 Intent intent = new Intent(Intent.ACTION_EDIT); 946 intent.setData(contactUri); 947 intent.putExtra(Intents.Insert.EMAIL, email); 948 if (intent.resolveActivity(getPackageManager()) != null) { 949 startActivity(intent); 950 } 951 } 952 </pre> 953 954 <p>For more information about how to edit a contact, read <a 955 href="{@docRoot}training/contacts-provider/modify-data.html">Modifying 956 Contacts Using Intents</a>.</p> 957 958 959 960 961 <h3 id="InsertContact">Insert a contact</h3> 962 963 <p>To insert a new contact, use the {@link android.content.Intent#ACTION_INSERT} action, 964 specify {@link android.provider.ContactsContract.Contacts#CONTENT_TYPE Contacts.CONTENT_TYPE} as 965 the MIME type, and include any known contact information in extras specified by 966 constants in {@link android.provider.ContactsContract.Intents.Insert}. 967 968 <dl> 969 <dt><b>Action</b></dt> 970 <dd>{@link android.content.Intent#ACTION_INSERT}</dd> 971 972 <dt><b>Data URI Scheme</b></dt> 973 <dd>None</dd> 974 975 <dt><b>MIME Type</b></dt> 976 <dd>{@link android.provider.ContactsContract.Contacts#CONTENT_TYPE Contacts.CONTENT_TYPE}</dd> 977 978 <dt><b>Extras</b></dt> 979 <dd>One or more of the extras defined in {@link android.provider.ContactsContract.Intents.Insert}. 980 </dd> 981 </dl> 982 983 <p><b>Example intent:</b></p> 984 <pre> 985 public void insertContact(String name, String email) { 986 Intent intent = new Intent(Intent.ACTION_INSERT); 987 intent.setType(Contacts.CONTENT_TYPE); 988 intent.putExtra(Intents.Insert.NAME, name); 989 intent.putExtra(Intents.Insert.EMAIL, email); 990 if (intent.resolveActivity(getPackageManager()) != null) { 991 startActivity(intent); 992 } 993 } 994 </pre> 995 996 <p>For more information about how to insert a contact, read <a 997 href="{@docRoot}training/contacts-provider/modify-data.html">Modifying 998 Contacts Using Intents</a>.</p> 999 1000 1001 1002 1003 1004 1005 1006 <h2 id="Email">Email</h2> 1007 1008 1009 <h3 id="ComposeEmail">Compose an email with optional attachments</h3> 1010 1011 <p>To compose an email, use one of the below actions based on whether you'll include attachments, 1012 and include email details such as the recipient and subject using the extra keys listed below.</p> 1013 1014 <dl> 1015 <dt><b>Action</b></dt> 1016 <dd>{@link android.content.Intent#ACTION_SENDTO} (for no attachment) or<br> 1017 {@link android.content.Intent#ACTION_SEND} (for one attachment) or<br> 1018 {@link android.content.Intent#ACTION_SEND_MULTIPLE} (for multiple attachments)</dd> 1019 1020 <dt><b>Data URI Scheme</b></dt> 1021 <dd>None</dd> 1022 1023 <dt><b>MIME Type</b></dt> 1024 <dd> 1025 <dl> 1026 <dt><code>"text/plain"</code> 1027 <dt><code>"*/*"</code> 1028 </dl> 1029 </dd> 1030 1031 <dt><b>Extras</b></dt> 1032 <dd> 1033 <dl> 1034 <dt>{@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}</dt> 1035 <dd>A string array of all "To" recipient email addresses.</dd> 1036 <dt>{@link android.content.Intent#EXTRA_CC Intent.EXTRA_CC}</dt> 1037 <dd>A string array of all "CC" recipient email addresses.</dd> 1038 <dt>{@link android.content.Intent#EXTRA_BCC Intent.EXTRA_BCC}</dt> 1039 <dd>A string array of all "BCC" recipient email addresses.</dd> 1040 <dt>{@link android.content.Intent#EXTRA_SUBJECT Intent.EXTRA_SUBJECT}</dt> 1041 <dd>A string with the email subject.</dd> 1042 <dt>{@link android.content.Intent#EXTRA_TEXT Intent.EXTRA_TEXT}</dt> 1043 <dd>A string with the body of the email.</dd> 1044 <dt>{@link android.content.Intent#EXTRA_STREAM Intent.EXTRA_STREAM}</dt> 1045 <dd>A {@link android.net.Uri} pointing to the attachment. If using the 1046 {@link android.content.Intent#ACTION_SEND_MULTIPLE} action, this should instead 1047 be an {@link java.util.ArrayList} containing multiple {@link android.net.Uri} objects.</dd> 1048 </dl> 1049 </dd> 1050 1051 </dl> 1052 1053 1054 <p><b>Example intent:</b></p> 1055 <pre> 1056 public void composeEmail(String[] addresses, String subject, Uri attachment) { 1057 Intent intent = new Intent(Intent.ACTION_SEND); 1058 intent.setType("*/*"); 1059 intent.putExtra(Intent.EXTRA_EMAIL, addresses); 1060 intent.putExtra(Intent.EXTRA_SUBJECT, subject); 1061 intent.putExtra(Intent.EXTRA_STREAM, attachment); 1062 if (intent.resolveActivity(getPackageManager()) != null) { 1063 startActivity(intent); 1064 } 1065 } 1066 </pre> 1067 1068 <p>If you want to ensure that your intent is handled only by an email app (and not other 1069 text messaging or social apps), then use the {@link android.content.Intent#ACTION_SENDTO} action 1070 and include the {@code "mailto:"} data scheme. For example:</p> 1071 1072 <pre> 1073 public void composeEmail(String[] addresses, String subject) { 1074 Intent intent = new Intent(Intent.ACTION_SENDTO); 1075 intent.setData(Uri.parse("mailto:")); // only email apps should handle this 1076 intent.putExtra(Intent.EXTRA_EMAIL, addresses); 1077 intent.putExtra(Intent.EXTRA_SUBJECT, subject); 1078 if (intent.resolveActivity(getPackageManager()) != null) { 1079 startActivity(intent); 1080 } 1081 } 1082 </pre> 1083 1084 1085 <p><b>Example intent filter:</b></p> 1086 <pre> 1087 <activity ...> 1088 <intent-filter> 1089 <action android:name="android.intent.action.SEND" /> 1090 <data android:type="*/*" /> 1091 <category android:name="android.intent.category.DEFAULT" /> 1092 </intent-filter> 1093 <intent-filter> 1094 <action android:name="android.intent.action.SENDTO" /> 1095 <data android:scheme="mailto" /> 1096 <category android:name="android.intent.category.DEFAULT" /> 1097 </intent-filter> 1098 </activity> 1099 </pre> 1100 1101 1102 1103 1104 1105 1106 1107 <h2 id="Storage">File Storage</h2> 1108 1109 1110 1111 <h3 id="GetFile">Retrieve a specific type of file</h3> 1112 1113 <p>To request that the user select a file such as a document or photo and return a reference to 1114 your app, use the {@link android.content.Intent#ACTION_GET_CONTENT} action and specify your desired 1115 MIME type. The file reference returned to your app is transient to your activity's current 1116 lifecycle, so if you want to access it later you must import a copy that you can read later. 1117 This intent also allows the user to create a new file in the process (for 1118 example, instead of selecting an existing photo, the user can capture a new photo with the camera). 1119 </p> 1120 1121 <p>The result intent delivered to your {@link android.app.Activity#onActivityResult 1122 onActivityResult()} method includes data with a URI pointing to the file. 1123 The URI could be anything, such as an {@code http:} URI, {@code file:} URI, or {@code content:} 1124 URI. However, if you'd like to restrict selectable files to only those that are accessible 1125 from a content provider (a {@code content:} URI) and that are available as a file stream with {@link 1126 android.content.ContentResolver#openFileDescriptor openFileDescriptor()}, you should add 1127 the {@link android.content.Intent#CATEGORY_OPENABLE} category to your intent.</p> 1128 1129 <p>On Android 4.3 (API level 18) and higher, 1130 you can also allow the user to select multiple files by adding 1131 {@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} to the intent, set to {@code true}. 1132 You can then access each of the selected files in a {@link android.content.ClipData} 1133 object returned by {@link android.content.Intent#getClipData()}.</p> 1134 1135 1136 <dl> 1137 <dt><b>Action</b></dt> 1138 <dd>{@link android.content.Intent#ACTION_GET_CONTENT}</dd> 1139 1140 <dt><b>Data URI Scheme</b></dt> 1141 <dd>None</dd> 1142 1143 <dt><b>MIME Type</b></dt> 1144 <dd>The MIME type corresponding to the file type the user should select. 1145 </dd> 1146 1147 <dt><b>Extras</b></dt> 1148 <dd> 1149 <dl> 1150 <dt>{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} 1151 <dd>A boolean declaring whether the user can select more than one file at a time. 1152 </dd> 1153 <dt>{@link android.content.Intent#EXTRA_LOCAL_ONLY} 1154 <dd>A boolean that declares whether the returned file must be available directly from 1155 the device, rather than requiring a download from a remote service. 1156 </dd> 1157 </dl> 1158 </dd> 1159 1160 <dt><b>Category</b> (optional)</dt> 1161 <dd> 1162 <dl> 1163 <dt>{@link android.content.Intent#CATEGORY_OPENABLE}</dt> 1164 <dd>To return only "openable" files that can be represented as a file stream 1165 with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()}.</dd> 1166 </dl> 1167 </dd> 1168 1169 </dl> 1170 1171 <p><b>Example intent to get a photo:</b></p> 1172 <pre> 1173 static final int REQUEST_IMAGE_GET = 1; 1174 1175 public void selectImage() { 1176 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 1177 intent.setType("image/*"); 1178 if (intent.resolveActivity(getPackageManager()) != null) { 1179 startActivityForResult(intent, REQUEST_IMAGE_GET); 1180 } 1181 } 1182 1183 @Override 1184 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 1185 if (requestCode == REQUEST_IMAGE_GET && resultCode == RESULT_OK) { 1186 Bitmap thumbnail = data.getParcelable("data"); 1187 Uri fullPhotoUri = data.getData(); 1188 // Do work with photo saved at fullPhotoUri 1189 ... 1190 } 1191 } 1192 </pre> 1193 1194 <p><b>Example intent filter to return a photo:</b></p> 1195 <pre> 1196 <activity ...> 1197 <intent-filter> 1198 <action android:name="android.intent.action.GET_CONTENT" /> 1199 <data android:type="image/*" /> 1200 <category android:name="android.intent.category.DEFAULT" /> 1201 <!-- The OPENABLE category declares that the returned file is accessible 1202 from a content provider that supports {@link android.provider.OpenableColumns} 1203 and {@link android.content.ContentResolver#openFileDescriptor ContentResolver.openFileDescriptor()} --> 1204 <category android:name="android.intent.category.OPENABLE" /> 1205 </intent-filter> 1206 </activity> 1207 </pre> 1208 1209 1210 1211 1212 1213 1214 <h3 id="OpenFile">Open a specific type of file</h3> 1215 1216 <p>Instead of retrieving a copy of a file that you must import to your app 1217 (by using the {@link android.content.Intent#ACTION_GET_CONTENT} action), when running on Android 1218 4.4 or higher, you can instead request to <em>open</em> a file that's managed by another app by 1219 using the {@link android.content.Intent#ACTION_OPEN_DOCUMENT} action and specifying a MIME type. 1220 To also allow the user to instead create a new document that your app can write to, use the {@link 1221 android.content.Intent#ACTION_CREATE_DOCUMENT} action instead. For example, instead of 1222 selecting from existing PDF documents, the {@link android.content.Intent#ACTION_CREATE_DOCUMENT} 1223 intent allows users to select where they'd like to create a new document (within another app 1224 that manages the document's storage)—your app then receives the URI location of where it 1225 can write the new document.</p> 1226 1227 <p>Whereas the intent delivered to your {@link android.app.Activity#onActivityResult 1228 onActivityResult()} method from the {@link android.content.Intent#ACTION_GET_CONTENT} action may 1229 return a URI of any type, the result intent from {@link android.content.Intent#ACTION_OPEN_DOCUMENT} 1230 and {@link android.content.Intent#ACTION_CREATE_DOCUMENT} always specify the chosen file as a {@code 1231 content:} URI that's backed by a {@link android.provider.DocumentsProvider}. You can open the 1232 file with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()} and 1233 query its details using columns from {@link android.provider.DocumentsContract.Document}.</p> 1234 1235 <p>The returned URI grants your app long-term read access to the file (also possibly 1236 with write access). So the {@link android.content.Intent#ACTION_OPEN_DOCUMENT} action is 1237 particularly useful (instead of using {@link android.content.Intent#ACTION_GET_CONTENT}) 1238 when you want to read an existing file without making a copy into your app, 1239 or when you want to open and edit a file in place.</p> 1240 1241 <p>You can also allow the user to select multiple files by adding 1242 {@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} to the intent, set to {@code true}. 1243 If the user selects just one item, then you can retrieve the item from {@link 1244 android.content.Intent#getData()}. If the user selects more than one item, then {@link 1245 android.content.Intent#getData()} returns null and you must instead 1246 retrieve each item from a {@link android.content.ClipData} 1247 object that is returned by {@link android.content.Intent#getClipData()}.</p> 1248 1249 <p class="note"><strong>Note:</strong> Your intent <strong>must</strong> specify a MIME type and 1250 <strong>must</strong> declare the {@link android.content.Intent#CATEGORY_OPENABLE} category. If 1251 appropriate, you can specify more than one MIME type by adding an array of MIME types with the 1252 {@link android.content.Intent#EXTRA_MIME_TYPES} extra—if you do so, you must set the 1253 primary MIME type in {@link android.content.Intent#setType setType()} to {@code "*/*"}.</p> 1254 1255 <dl> 1256 <dt><b>Action</b></dt> 1257 <dd>{@link android.content.Intent#ACTION_OPEN_DOCUMENT} or<br/> 1258 {@link android.content.Intent#ACTION_CREATE_DOCUMENT}</dd> 1259 1260 <dt><b>Data URI Scheme</b></dt> 1261 <dd>None</dd> 1262 1263 <dt><b>MIME Type</b></dt> 1264 <dd>The MIME type corresponding to the file type the user should select. 1265 </dd> 1266 1267 <dt><b>Extras</b></dt> 1268 <dd> 1269 <dl> 1270 <dt>{@link android.content.Intent#EXTRA_MIME_TYPES} 1271 <dd>An array of MIME types corresponding to the types of files your app is 1272 requesting. When you use this extra, you must set the primary MIME type in 1273 {@link android.content.Intent#setType setType()} to {@code "*/*"}.</dd> 1274 <dt>{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} 1275 <dd>A boolean that declares whether the user can select more than one file at a time. 1276 </dd> 1277 <dt>{@link android.content.Intent#EXTRA_TITLE} 1278 <dd>For use with {@link android.content.Intent#ACTION_CREATE_DOCUMENT} to specify 1279 an initial file name. 1280 </dd> 1281 <dt>{@link android.content.Intent#EXTRA_LOCAL_ONLY} 1282 <dd>A boolean that declares whether the returned file must be available directly from 1283 the device, rather than requiring a download from a remote service. 1284 </dd> 1285 </dl> 1286 </dd> 1287 1288 <dt><b>Category</b></dt> 1289 <dd> 1290 <dl> 1291 <dt>{@link android.content.Intent#CATEGORY_OPENABLE}</dt> 1292 <dd>To return only "openable" files that can be represented as a file stream 1293 with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()}.</dd> 1294 </dl> 1295 </dd> 1296 1297 </dl> 1298 1299 <p><b>Example intent to get a photo:</b></p> 1300 <pre> 1301 static final int REQUEST_IMAGE_OPEN = 1; 1302 1303 public void selectImage() { 1304 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 1305 intent.setType("image/*"); 1306 intent.addCategory(Intent.CATEGORY_OPENABLE); 1307 // Only the system receives the ACTION_OPEN_DOCUMENT, so no need to test. 1308 startActivityForResult(intent, REQUEST_IMAGE_OPEN); 1309 } 1310 1311 @Override 1312 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 1313 if (requestCode == REQUEST_IMAGE_OPEN && resultCode == RESULT_OK) { 1314 Uri fullPhotoUri = data.getData(); 1315 // Do work with full size photo saved at fullPhotoUri 1316 ... 1317 } 1318 } 1319 </pre> 1320 1321 <p>Third party apps cannot actually respond to an intent with the 1322 {@link android.content.Intent#ACTION_OPEN_DOCUMENT} action. Instead, the system receives this 1323 intent and displays all the files available from various apps in a unified user interface.</p> 1324 1325 <p>To provide your app's files in this UI and allow other apps to open them, you must implement 1326 a {@link android.provider.DocumentsProvider} and include an intent filter for 1327 {@link android.provider.DocumentsContract#PROVIDER_INTERFACE} 1328 ({@code "android.content.action.DOCUMENTS_PROVIDER"}). For example: 1329 1330 <pre> 1331 <provider ... 1332 android:grantUriPermissions="true" 1333 android:exported="true" 1334 android:permission="android.permission.MANAGE_DOCUMENTS"> 1335 <intent-filter> 1336 <action android:name="android.content.action.DOCUMENTS_PROVIDER" /> 1337 </intent-filter> 1338 </provider> 1339 </pre> 1340 1341 <p>For more information about how to make the files managed by your app openable from other apps, 1342 read the <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage Access 1343 Framework</a> guide.</p> 1344 1345 1346 1347 <h2 id="Local">Local Actions</h2> 1348 1349 <h3 id="CallCar">Call a car</h3> 1350 1351 <!-- Google Now box --> 1352 <div class="now-box"> 1353 <div class="now-img-cont"> 1354 <a href="#Now"> 1355 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 1356 width="30" height="30" alt=""/> 1357 </a> 1358 </div> 1359 <p class="now-title">Google Now</p> 1360 <ul> 1361 <li>"get me a taxi"</li> 1362 <li>"call me a car"</li> 1363 </ul> 1364 <p style="font-size:13px;margin-bottom:0px;margin-top:10px">(Android Wear only)</p> 1365 </div> 1366 1367 <p>To call a taxi, use the 1368 <a href="{@docRoot}reference/com/google/android/gms/actions/ReserveIntents.html#ACTION_RESERVE_TAXI_RESERVATION"><code>ACTION_RESERVE_TAXI_RESERVATION</code></a> 1369 action.</p> 1370 1371 <p class="note"><strong>Note:</strong> Apps must ask for confirmation from the user 1372 before completing the action.</p> 1373 1374 <dl> 1375 <dt><b>Action</b></dt> 1376 <dd><a href="{@docRoot}reference/com/google/android/gms/actions/ReserveIntents.html#ACTION_RESERVE_TAXI_RESERVATION"><code>ACTION_RESERVE_TAXI_RESERVATION</code></a></dd> 1377 1378 <dt><b>Data URI</b></dt> 1379 <dd>None</dd> 1380 1381 <dt><b>MIME Type</b></dt> 1382 <dd>None</dd> 1383 1384 <dt><b>Extras</b></dt> 1385 <dd>None</dd> 1386 </dl> 1387 1388 1389 <p><b>Example intent:</b></p> 1390 <pre> 1391 public void callCar() { 1392 Intent intent = new Intent(ReserveIntents.ACTION_RESERVE_TAXI_RESERVATION); 1393 if (intent.resolveActivity(getPackageManager()) != null) { 1394 startActivity(intent); 1395 } 1396 } 1397 </pre> 1398 1399 1400 <p><b>Example intent filter:</b></p> 1401 <pre> 1402 <activity ...> 1403 <intent-filter> 1404 <action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" /> 1405 <category android:name="android.intent.category.DEFAULT" /> 1406 </intent-filter> 1407 </activity> 1408 </pre> 1409 1410 1411 1412 1413 1414 1415 1416 1417 <h2 id="Maps">Maps</h2> 1418 1419 <h3 id="ViewMap">Show a location on a map</h3> 1420 1421 <p>To open a map, use the {@link android.content.Intent#ACTION_VIEW} action and specify 1422 the location information in the intent data with one of the schemes defined below.</p> 1423 1424 <dl> 1425 <dt><b>Action</b></dt> 1426 <dd>{@link android.content.Intent#ACTION_VIEW}</dd> 1427 1428 <dt><b>Data URI Scheme</b></dt> 1429 <dd> 1430 <dl> 1431 <dt><code>geo:<em>latitude</em>,<em>longitude</em></code></dt> 1432 <dd>Show the map at the given longitude and latitude. 1433 <p>Example: <code>"geo:47.6,-122.3"</code> 1434 </dd> 1435 <dt><code>geo:<em>latitude</em>,<em>longitude</em>?z=<em>zoom</em></code></dt> 1436 <dd>Show the map at the given longitude and latitude at a certain zoom level. A zoom level of 1437 1 shows the whole Earth, centered at the given <em>lat</em>,<em>lng</em>. The highest 1438 (closest) zoom level is 23. 1439 <p>Example: <code>"geo:47.6,-122.3?z=11"</code> 1440 </dd> 1441 <dt><code>geo:0,0?q=lat,lng(label)</code></dt> 1442 <dd>Show the map at the given longitude and latitude with a string label. 1443 <p>Example: <code>"geo:0,0?q=34.99,-106.61(Treasure)"</code> 1444 </dd> 1445 <dt><code>geo:0,0?q=my+street+address</code></dt> 1446 <dd>Show the location for "my street address" (may be a specific address or location query). 1447 <p>Example: <code>"geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA"</code></p> 1448 <p class="note"><strong>Note:</strong> All strings passed in the {@code geo} URI must 1449 be encoded. For example, the string {@code 1st & Pike, Seattle} should become 1450 {@code 1st%20%26%20Pike%2C%20Seattle}. Spaces in the string can be encoded with 1451 {@code %20} or replaced with the plus sign ({@code +}).</p> 1452 </dd> 1453 </dl> 1454 </dd> 1455 1456 <dt><b>MIME Type</b></dt> 1457 <dd>None</dd> 1458 1459 </dl> 1460 1461 <p><b>Example intent:</b></p> 1462 <pre> 1463 public void showMap(Uri geoLocation) { 1464 Intent intent = new Intent(Intent.ACTION_VIEW); 1465 intent.setData(geoLocation); 1466 if (intent.resolveActivity(getPackageManager()) != null) { 1467 startActivity(intent); 1468 } 1469 } 1470 </pre> 1471 1472 <p><b>Example intent filter:</b></p> 1473 <pre> 1474 <activity ...> 1475 <intent-filter> 1476 <action android:name="android.intent.action.VIEW" /> 1477 <data android:scheme="geo" /> 1478 <category android:name="android.intent.category.DEFAULT" /> 1479 </intent-filter> 1480 </activity> 1481 </pre> 1482 1483 1484 1485 1486 1487 1488 1489 1490 <h2 id="Music">Music or Video</h2> 1491 1492 1493 <h3 id="PlayMedia">Play a media file</h3> 1494 1495 <p>To play a music file, use the {@link android.content.Intent#ACTION_VIEW} action and 1496 specify the URI location of the file in the intent data.</p> 1497 1498 <dl> 1499 <dt><b>Action</b></dt> 1500 <dd>{@link android.content.Intent#ACTION_VIEW}</dd> 1501 1502 <dt><b>Data URI Scheme</b></dt> 1503 <dd> 1504 <dl> 1505 <dt><code>file:<em><URI></em></code> 1506 <dt><code>content:<em><URI></em></code> 1507 <dt><code>http:<em><URL></em></code> 1508 </dl> 1509 </dd> 1510 1511 <dt><b>MIME Type</b></dt> 1512 <dd> 1513 <dl> 1514 <dt><code>"audio/*"</code> 1515 <dt><code>"application/ogg"</code> 1516 <dt><code>"application/x-ogg"</code> 1517 <dt><code>"application/itunes"</code> 1518 <dt>Or any other that your app may require. 1519 </dl> 1520 </dd> 1521 1522 </dl> 1523 1524 <p><b>Example intent:</b></p> 1525 <pre> 1526 public void playMedia(Uri file) { 1527 Intent intent = new Intent(Intent.ACTION_VIEW); 1528 intent.setData(file); 1529 if (intent.resolveActivity(getPackageManager()) != null) { 1530 startActivity(intent); 1531 } 1532 } 1533 </pre> 1534 1535 1536 <p><b>Example intent filter:</b></p> 1537 <pre> 1538 <activity ...> 1539 <intent-filter> 1540 <action android:name="android.intent.action.VIEW" /> 1541 <data android:type="audio/*" /> 1542 <data android:type="application/ogg" /> 1543 <category android:name="android.intent.category.DEFAULT" /> 1544 </intent-filter> 1545 </activity> 1546 </pre> 1547 1548 1549 <h3 id="PlaySearch">Play music based on a search query</h3> 1550 1551 <!-- Google Now box --> 1552 <div class="now-box"> 1553 <div class="now-img-cont"> 1554 <a href="#Now"> 1555 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 1556 width="30" height="30" alt=""/> 1557 </a> 1558 </div> 1559 <p class="now-title">Google Now</p> 1560 <ul> 1561 <li>"play michael jackson billie jean"</li> 1562 </ul> 1563 </div> 1564 1565 <p>To play music based on a search query, use the 1566 {@link android.provider.MediaStore#INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH} intent. An app may fire 1567 this intent in response to the user's voice command to play music. The receiving app for this 1568 intent performs a search within its inventory to match existing content to the given query and 1569 starts playing that content.</p> 1570 1571 <p>This intent should include the {@link android.provider.MediaStore#EXTRA_MEDIA_FOCUS} string 1572 extra, which specifies the inteded search mode. For example, the search mode can specify whether 1573 the search is for an artist name or song name.</p> 1574 1575 <dl> 1576 <dt><b>Action</b></dt> 1577 <dd>{@link android.provider.MediaStore#INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH}</dd> 1578 1579 <dt><b>Data URI Scheme</b></dt> 1580 <dd>None</dd> 1581 1582 <dt><b>MIME Type</b></dt> 1583 <dd>None</dd> 1584 1585 <dt><b>Extras</b></dt> 1586 <dd> 1587 <dl> 1588 <dt>{@link android.provider.MediaStore#EXTRA_MEDIA_FOCUS MediaStore.EXTRA_MEDIA_FOCUS} (required)</dt> 1589 <dd> 1590 <p>Indicates the search mode (whether the user is looking for a particular artist, album, song, 1591 or playlist). Most search modes take additional extras. For example, if the user 1592 is interested in listening to a particular song, the intent might have three additional extras: 1593 the song title, the artist, and the album. This intent supports the following search modes for 1594 each value of {@link android.provider.MediaStore#EXTRA_MEDIA_FOCUS}:</p> 1595 <dl> 1596 <dt><p><em>Any</em> - <code>"vnd.android.cursor.item/*"</p></code></dt> 1597 <dd> 1598 <p>Play any music. The receiving app should play some music based on a smart choice, such 1599 as the last playlist the user listened to.</p> 1600 <p>Additional extras:</p> 1601 <ul> 1602 <li>{@link android.app.SearchManager#QUERY} (required) - An empty string. This extra is always 1603 provided for backward compatibility: existing apps that do not know about search modes can 1604 process this intent as an unstructured search.</li> 1605 </ul> 1606 </dd> 1607 <dt><p><em>Unstructured</em> - <code>"vnd.android.cursor.item/*"</code></p></dt> 1608 <dd> 1609 <p>Play a particular song, album or genre from an unstructured search query. Apps may generate 1610 an intent with this search mode when they can't identify the type of content the user wants to 1611 listen to. Apps should use more specific search modes when possible.</p> 1612 <p>Additional extras:</p> 1613 <ul> 1614 <li>{@link android.app.SearchManager#QUERY} (required) - A string that contains any combination 1615 of: the artist, the album, the song name, or the genre.</li> 1616 </ul> 1617 </dd> 1618 <dt><p><em>Genre</em> - 1619 {@link android.provider.MediaStore.Audio.Genres#ENTRY_CONTENT_TYPE Audio.Genres.ENTRY_CONTENT_TYPE}</p></dt> 1620 <dd> 1621 <p>Play music of a particular genre.</p> 1622 <p>Additional extras:</p> 1623 <ul> 1624 <li><code>"android.intent.extra.genre"</code> (required) - The genre.</li> 1625 <li>{@link android.app.SearchManager#QUERY} (required) - The genre. This extra is always provided 1626 for backward compatibility: existing apps that do not know about search modes can process 1627 this intent as an unstructured search.</li> 1628 </ul> 1629 </dd> 1630 <dt><p><em>Artist</em> - 1631 {@link android.provider.MediaStore.Audio.Artists#ENTRY_CONTENT_TYPE Audio.Artists.ENTRY_CONTENT_TYPE}</p></dt> 1632 <dd> 1633 <p>Play music from a particular artist.</p> 1634 <p>Additional extras:</p> 1635 <ul> 1636 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ARTIST} (required) - The artist.</li> 1637 <li><code>"android.intent.extra.genre"</code> - The genre.</li> 1638 <li>{@link android.app.SearchManager#QUERY} (required) - A string that contains any combination of 1639 the artist or the genre. This extra is always provided for backward compatibility: 1640 existing apps that do not know about search modes can process this intent as an unstructured 1641 search.</li> 1642 </ul> 1643 </dd> 1644 <dt><p><em>Album</em> - 1645 {@link android.provider.MediaStore.Audio.Albums#ENTRY_CONTENT_TYPE Audio.Albums.ENTRY_CONTENT_TYPE}</p></dt> 1646 <dd> 1647 <p>Play music from a particular album.</p> 1648 <p>Additional extras:</p> 1649 <ul> 1650 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ALBUM} (required) - The album.</li> 1651 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ARTIST} - The artist.</li> 1652 <li><code>"android.intent.extra.genre"</code> - The genre.</li> 1653 <li>{@link android.app.SearchManager#QUERY} (required) - A string that contains any combination of 1654 the album or the artist. This extra is always provided for backward 1655 compatibility: existing apps that do not know about search modes can process this intent as an 1656 unstructured search.</li> 1657 </ul> 1658 </dd> 1659 <dt><p><em>Song</em> - <code>"vnd.android.cursor.item/audio"</code></p></dt> 1660 <dd> 1661 <p>Play a particular song.</p> 1662 <p>Additional extras:</p> 1663 <ul> 1664 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ALBUM} - The album.</li> 1665 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ARTIST} - The artist.</li> 1666 <li><code>"android.intent.extra.genre"</code> - The genre.</li> 1667 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_TITLE} (required) - The song name.</li> 1668 <li>{@link android.app.SearchManager#QUERY} (required) - A string that contains any combination of: 1669 the album, the artist, the genre, or the title. This extra is always provided for 1670 backward compatibility: existing apps that do not know about search modes can process this 1671 intent as an unstructured search.</li> 1672 </ul> 1673 </dd> 1674 <dt><p><em>Playlist</em> - {@link android.provider.MediaStore.Audio.Playlists#ENTRY_CONTENT_TYPE Audio.Playlists.ENTRY_CONTENT_TYPE}</p></dt> 1675 <dd> 1676 <p>Play a particular playlist or a playlist that matches some criteria specified 1677 by additional extras.</p> 1678 <p>Additional extras:</p> 1679 <ul> 1680 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ALBUM} - The album.</li> 1681 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_ARTIST} - The artist.</li> 1682 <li><code>"android.intent.extra.genre"</code> - The genre.</li> 1683 <li><code>"android.intent.extra.playlist"</code> - The playlist.</li> 1684 <li>{@link android.provider.MediaStore#EXTRA_MEDIA_TITLE} - The song name that the playlist is 1685 based on.</li> 1686 <li>{@link android.app.SearchManager#QUERY} (required) - A string that contains any combination 1687 of: the album, the artist, the genre, the playlist, or the title. This extra is always 1688 provided for backward compatibility: existing apps that do not know about search modes can 1689 process this intent as an unstructured search.</li> 1690 </ul> 1691 </dd> 1692 </dl> 1693 </dd> 1694 </dl> 1695 </dd> 1696 </dl> 1697 1698 1699 1700 <p><b>Example intent:</b></p> 1701 <p>If the user wants to listen to music from a particular artist, a search app may generate the 1702 following intent:</p> 1703 <pre> 1704 public void playSearchArtist(String artist) { 1705 Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH); 1706 intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, 1707 MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE); 1708 intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist); 1709 intent.putExtra(SearchManager.QUERY, artist); 1710 if (intent.resolveActivity(getPackageManager()) != null) { 1711 startActivity(intent); 1712 } 1713 } 1714 </pre> 1715 1716 <p><b>Example intent filter:</b></p> 1717 <pre> 1718 <activity ...> 1719 <intent-filter> 1720 <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" /> 1721 <category android:name="android.intent.category.DEFAULT" /> 1722 </intent-filter> 1723 </activity> 1724 </pre> 1725 <p>When handling this intent, your activity should check the value of the 1726 {@link android.provider.MediaStore#EXTRA_MEDIA_FOCUS} extra in the incoming 1727 {@link android.content.Intent} to determine the search mode. Once your activity has identified 1728 the search mode, it should read the values of the additional extras for that particular search mode. 1729 With this information your app can then perform the search within its inventory to play the 1730 content that matches the search query. For example:</p> 1731 <pre> 1732 protected void onCreate(Bundle savedInstanceState) { 1733 ... 1734 Intent intent = this.getIntent(); 1735 if (intent.getAction().compareTo(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) == 0) { 1736 1737 String mediaFocus = intent.getStringExtra(MediaStore.EXTRA_MEDIA_FOCUS); 1738 String query = intent.getStringExtra(SearchManager.QUERY); 1739 1740 // Some of these extras may not be available depending on the search mode 1741 String album = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ALBUM); 1742 String artist = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ARTIST); 1743 String genre = intent.getStringExtra("android.intent.extra.genre"); 1744 String playlist = intent.getStringExtra("android.intent.extra.playlist"); 1745 String title = intent.getStringExtra(MediaStore.EXTRA_MEDIA_TITLE); 1746 1747 // Determine the search mode and use the corresponding extras 1748 if (mediaFocus == null) { 1749 // 'Unstructured' search mode (backward compatible) 1750 playUnstructuredSearch(query); 1751 1752 } else if (mediaFocus.compareTo("vnd.android.cursor.item/*") == 0) { 1753 if (query.isEmpty()) { 1754 // 'Any' search mode 1755 playResumeLastPlaylist(); 1756 } else { 1757 // 'Unstructured' search mode 1758 playUnstructuredSearch(query); 1759 } 1760 1761 } else if (mediaFocus.compareTo(MediaStore.Audio.Genres.ENTRY_CONTENT_TYPE) == 0) { 1762 // 'Genre' search mode 1763 playGenre(genre); 1764 1765 } else if (mediaFocus.compareTo(MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE) == 0) { 1766 // 'Artist' search mode 1767 playArtist(artist, genre); 1768 1769 } else if (mediaFocus.compareTo(MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE) == 0) { 1770 // 'Album' search mode 1771 playAlbum(album, artist); 1772 1773 } else if (mediaFocus.compareTo("vnd.android.cursor.item/audio") == 0) { 1774 // 'Song' search mode 1775 playSong(album, artist, genre, title); 1776 1777 } else if (mediaFocus.compareTo(MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE) == 0) { 1778 // 'Playlist' search mode 1779 playPlaylist(album, artist, genre, playlist, title); 1780 } 1781 } 1782 } 1783 </pre> 1784 1785 1786 1787 1788 <h2 id="NewNote">New Note</h2> 1789 1790 <h3 id="CreateNote">Create a note</h3> 1791 1792 <p>To create a new note, use the 1793 <a href="https://developers.google.com/android/reference/com/google/android/gms/actions/NoteIntents#ACTION_CREATE_NOTE"> 1794 {@code ACTION_CREATE_NOTE}</a> action and specify note details such as the subject and text using extras defined below.</p> 1795 1796 <p class="note"><strong>Note:</strong> Apps must ask for confirmation from the user 1797 before completing the action.</p> 1798 1799 <dl> 1800 <dt><b>Action</b></dt> 1801 <dd><a href="https://developers.google.com/android/reference/com/google/android/gms/actions/NoteIntents#ACTION_CREATE_NOTE"> 1802 {@code ACTION_CREATE_NOTE}</a> 1803 </dd> 1804 1805 <dt><b>Data URI Scheme</b></dt> 1806 <dd>None</dd> 1807 1808 <dt><b>MIME Type</b></dt> 1809 <dd><a href="https://developer.android.com/reference/org/apache/http/protocol/HTTP.html#PLAIN_TEXT_TYPE"> 1810 {@code PLAIN_TEXT_TYPE}</a></dd> 1811 <dd>"*/*"</dd> 1812 1813 1814 <dt><b>Extras</b></dt> 1815 <dd> 1816 <dl> 1817 <dt><a href="https://developers.google.com/android/reference/com/google/android/gms/actions/NoteIntents#EXTRA_NAME"> 1818 {@code EXTRA_NAME}</a> 1819 <dd>A string indicating the title or subject of the note.</dd> 1820 <dt><a href="https://developers.google.com/android/reference/com/google/android/gms/actions/NoteIntents#EXTRA_TEXT"> 1821 {@code EXTRA_TEXT}</a> 1822 <dd>A string indicating the text of the note.</dd> 1823 </dl> 1824 </dd> 1825 1826 1827 <p><b>Example intent:</b></p> 1828 <pre> 1829 public void createNote(String subject, String text) { 1830 Intent intent = new Intent(NoteIntents.ACTION_CREATE_NOTE) 1831 .putExtra(NoteIntents.EXTRA_NAME, subject) 1832 .putExtra(NoteIntents.EXTRA_TEXT, text); 1833 if (intent.resolveActivity(getPackageManager()) != null) { 1834 startActivity(intent); 1835 } 1836 }</pre> 1837 1838 1839 <p><b>Example intent filter:</b></p> 1840 <pre> 1841 <activity ...> 1842 <intent-filter> 1843 <action android:name="com.google.android.gms.actions.CREATE_NOTE" /> 1844 <category android:name="android.intent.category.DEFAULT" /> 1845 <data android:mimeType=*/*> 1846 </intent-filter> 1847 </activity> 1848 </pre> 1849 1850 1851 1852 1853 1854 <h2 id="Phone">Phone</h2> 1855 1856 1857 <h3 id="DialPhone">Initiate a phone call</h3> 1858 1859 <p>To open the phone app and dial a phone number, use the {@link 1860 android.content.Intent#ACTION_DIAL} action and specify a phone number using 1861 the URI scheme defined below. When the phone app opens, it displays the phone number 1862 but the user must press the <em>Call</em> button to begin the phone call.</p> 1863 1864 <!-- Google Now box --> 1865 <div class="now-box"> 1866 <div class="now-img-cont"> 1867 <a href="#Now"> 1868 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 1869 width="30" height="30" alt=""/> 1870 </a> 1871 </div> 1872 <p class="now-title">Google Now</p> 1873 <ul> 1874 <li>"call 555-5555"</li> 1875 <li>"call bob"</li> 1876 <li>"call voicemail"</li> 1877 </ul> 1878 </div> 1879 1880 <p>To place a phone call directly, use the {@link android.content.Intent#ACTION_CALL} action 1881 and specify a phone number using the URI scheme defined below. When the phone app opens, it 1882 begins the phone call; the user does not need to press the <em>Call</em> button.</p> 1883 1884 <p>The {@link android.content.Intent#ACTION_CALL} action requires that you add the 1885 <code>CALL_PHONE</code> permission to your manifest file:</p> 1886 1887 <pre style="margin-top:45px"> 1888 <uses-permission android:name="android.permission.CALL_PHONE" /> 1889 </pre> 1890 1891 <dl> 1892 <dt><b>Action</b></dt> 1893 <dd> 1894 <ul> 1895 <li>{@link android.content.Intent#ACTION_DIAL} - Opens the dialer or phone app.</li> 1896 <li>{@link android.content.Intent#ACTION_CALL} - Places a phone call (requires the 1897 <code>CALL_PHONE</code> permission)</li> 1898 </ul> 1899 </dd> 1900 1901 <dt><b>Data URI Scheme</b></dt> 1902 <dd> 1903 <ul> 1904 <li>{@code tel:<phone-number>}</li> 1905 <li>{@code voicemail:<phone-number>}</li> 1906 </ul> 1907 </dd> 1908 1909 <dt><b>MIME Type</b></dt> 1910 <dd>None</dd> 1911 1912 </dl> 1913 1914 1915 <p>Valid telephone numbers are those defined 1916 in <a href="http://tools.ietf.org/html/rfc3966">the IETF RFC 3966</a>. 1917 Valid examples include the following:</p> 1918 <ul> 1919 <li><code>tel:2125551212</code> </li> 1920 <li><code>tel:(212) 555 1212</code></li> 1921 </ul> 1922 <p>The Phone's dialer is good at normalizing schemes, such as 1923 telephone numbers. So the scheme described isn't strictly required in the 1924 {@link android.net.Uri#parse(String) Uri.parse()} method. 1925 However, if you have not tried a scheme or are unsure whether it 1926 can be handled, use the {@link android.net.Uri#fromParts Uri.fromParts()} 1927 method instead.</p> 1928 1929 1930 <p><b>Example intent:</b></p> 1931 <pre> 1932 public void dialPhoneNumber(String phoneNumber) { 1933 Intent intent = new Intent(Intent.ACTION_DIAL); 1934 intent.setData(Uri.parse("tel:" + phoneNumber)); 1935 if (intent.resolveActivity(getPackageManager()) != null) { 1936 startActivity(intent); 1937 } 1938 } 1939 </pre> 1940 1941 1942 1943 1944 1945 1946 <h2 id="Search">Search</h2> 1947 1948 <h3 id="SearchOnApp">Search using a specific app</h3> 1949 1950 <!-- Google Now box --> 1951 <div class="now-box"> 1952 <div class="now-img-cont"> 1953 <a href="#Now"> 1954 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 1955 width="30" height="30"/></a> 1956 </div> 1957 <p class="now-title">Google Now</p> 1958 <ul> 1959 <li>"search for cat videos on myvideoapp"</li> 1960 </ul> 1961 </div> 1962 <!-- Video box --> 1963 <a class="notice-developers-video" 1964 href="https://www.youtube.com/watch?v=PS1FbB5qWEI"> 1965 <div> 1966 <h3>Video</h3> 1967 <p>Voice search in your app</p> 1968 </div> 1969 </a> 1970 1971 <p>To support search within the context of your app, declare an intent filter in your app with 1972 the <code>SEARCH_ACTION</code> action, as shown in the example intent filter below.</p> 1973 1974 <dl> 1975 <dt><b>Action</b></dt> 1976 <dd> 1977 <dl> 1978 <dt><code>"com.google.android.gms.actions.SEARCH_ACTION"</code></dt> 1979 <dd>Support search queries from Google Now.</dd> 1980 </dl> 1981 </dd> 1982 1983 <dt><b>Extras</b></dt> 1984 <dd> 1985 <dl> 1986 <dt><code>{@link android.app.SearchManager#QUERY}</code></dt> 1987 <dd>A string that contains the search query.</dd> 1988 <dl> 1989 </dd> 1990 </dl> 1991 1992 <p><b>Example intent filter:</b></p> 1993 <pre> 1994 <activity android:name=".SearchActivity"> 1995 <intent-filter> 1996 <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/> 1997 <category android:name="android.intent.category.DEFAULT"/> 1998 </intent-filter> 1999 </activity> 2000 </pre> 2001 2002 2003 2004 <h3 id="SearchWeb">Perform a web search</h3> 2005 2006 <p>To initiate a web search, use the {@link android.content.Intent#ACTION_WEB_SEARCH} action 2007 and specify the search string in the 2008 {@link android.app.SearchManager#QUERY SearchManager.QUERY} extra.</p> 2009 2010 2011 <dl> 2012 <dt><b>Action</b></dt> 2013 <dd>{@link android.content.Intent#ACTION_WEB_SEARCH}</dd> 2014 2015 <dt><b>Data URI Scheme</b></dt> 2016 <dd>None</dd> 2017 2018 <dt><b>MIME Type</b></dt> 2019 <dd>None</dd> 2020 2021 <dt><b>Extras</b></dt> 2022 <dd> 2023 <dl> 2024 <dt>{@link android.app.SearchManager#QUERY SearchManager.QUERY}</dt> 2025 <dd>The search string.</dd> 2026 </dl> 2027 </dd> 2028 </dl> 2029 2030 <p><b>Example intent:</b></p> 2031 <pre> 2032 public void searchWeb(String query) { 2033 Intent intent = new Intent(Intent.ACTION_SEARCH); 2034 intent.putExtra(SearchManager.QUERY, query); 2035 if (intent.resolveActivity(getPackageManager()) != null) { 2036 startActivity(intent); 2037 } 2038 } 2039 </pre> 2040 2041 2042 2043 2044 2045 2046 2047 <h2 id="Settings">Settings</h2> 2048 2049 <h3 id="OpenSettings">Open a specific section of Settings</h3> 2050 2051 <p>To open a screen in the system settings when your app requires the user to change something, 2052 use one of the following intent actions to open the settings screen respective to the action name. 2053 </p> 2054 2055 <dl> 2056 <dt><b>Action</b></dt> 2057 <dd> 2058 {@link android.provider.Settings#ACTION_SETTINGS}<br/> 2059 {@link android.provider.Settings#ACTION_WIRELESS_SETTINGS}<br/> 2060 {@link android.provider.Settings#ACTION_AIRPLANE_MODE_SETTINGS}<br/> 2061 {@link android.provider.Settings#ACTION_WIFI_SETTINGS}<br/> 2062 {@link android.provider.Settings#ACTION_APN_SETTINGS}<br/> 2063 {@link android.provider.Settings#ACTION_BLUETOOTH_SETTINGS}<br/> 2064 {@link android.provider.Settings#ACTION_DATE_SETTINGS}<br/> 2065 {@link android.provider.Settings#ACTION_LOCALE_SETTINGS}<br/> 2066 {@link android.provider.Settings#ACTION_INPUT_METHOD_SETTINGS}<br/> 2067 {@link android.provider.Settings#ACTION_DISPLAY_SETTINGS}<br/> 2068 {@link android.provider.Settings#ACTION_SECURITY_SETTINGS}<br/> 2069 {@link android.provider.Settings#ACTION_LOCATION_SOURCE_SETTINGS}<br/> 2070 {@link android.provider.Settings#ACTION_INTERNAL_STORAGE_SETTINGS}<br/> 2071 {@link android.provider.Settings#ACTION_MEMORY_CARD_SETTINGS}<br/> 2072 <p>See the {@link android.provider.Settings} documentation for additional settings screens 2073 that are available.</p> 2074 </dd> 2075 2076 <dt><b>Data URI Scheme</b></dt> 2077 <dd>None</dd> 2078 2079 <dt><b>MIME Type</b></dt> 2080 <dd>None</dd> 2081 2082 </dl> 2083 2084 <p><b>Example intent:</b></p> 2085 <pre> 2086 public void openWifiSettings() { 2087 Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS); 2088 if (intent.resolveActivity(getPackageManager()) != null) { 2089 startActivity(intent); 2090 } 2091 } 2092 </pre> 2093 2094 2095 2096 2097 2098 2099 2100 <h2 id="Messaging">Text Messaging</h2> 2101 2102 <h3 id="SendMessage">Compose an SMS/MMS message with attachment</h3> 2103 2104 <p>To initiate an SMS or MMS text message, use one of the intent actions below and specify message 2105 details such as the phone number, subject, and message body using the extra keys listed below.</p> 2106 2107 <dl> 2108 <dt><b>Action</b></dt> 2109 <dd>{@link android.content.Intent#ACTION_SENDTO} or<br> 2110 {@link android.content.Intent#ACTION_SEND} or<br> 2111 {@link android.content.Intent#ACTION_SEND_MULTIPLE}</dd> 2112 2113 <dt><b>Data URI Scheme</b></dt> 2114 <dd> 2115 <dl> 2116 <dt><code>sms:<em><phone_number></em></code> 2117 <dt><code>smsto:<em><phone_number></em></code> 2118 <dt><code>mms:<em><phone_number></em></code> 2119 <dt><code>mmsto:<em><phone_number></em></code> 2120 </dl> 2121 <p>Each of these schemes are handled the same. 2122 </dd> 2123 2124 <dt><b>MIME Type</b></dt> 2125 <dd> 2126 <dl> 2127 <dt><code>"text/plain"</code> 2128 <dt><code>"image/*"</code> 2129 <dt><code>"video/*"</code> 2130 </dl> 2131 </dd> 2132 2133 <dt><b>Extras</b></dt> 2134 <dd> 2135 <dl> 2136 <dt><code>"subject"</code></dt> 2137 <dd>A string for the message subject (usually for MMS only).</dd> 2138 <dt><code>"sms_body"</code></dt> 2139 <dd>A string for the text message.</dd> 2140 <dt>{@link android.content.Intent#EXTRA_STREAM}</dt> 2141 <dd>A {@link android.net.Uri} pointing to the 2142 image or video to attach. If using the {@link android.content.Intent#ACTION_SEND_MULTIPLE} action, 2143 this extra should be an {@link java.util.ArrayList} of {@link 2144 android.net.Uri}s pointing to the images/videos to attach.</dd> 2145 <dl> 2146 </dd> 2147 2148 </dl> 2149 2150 <p><b>Example intent:</b></p> 2151 <pre> 2152 public void composeMmsMessage(String message, Uri attachment) { 2153 Intent intent = new Intent(Intent.ACTION_SENDTO); 2154 intent.setType(HTTP.PLAIN_TEXT_TYPE); 2155 intent.putExtra("sms_body", message); 2156 intent.putExtra(Intent.EXTRA_STREAM, attachment); 2157 if (intent.resolveActivity(getPackageManager()) != null) { 2158 startActivity(intent); 2159 } 2160 } 2161 </pre> 2162 2163 <p>If you want to ensure that your intent is handled only by a text messaging app (and not other 2164 email or social apps), then use the {@link android.content.Intent#ACTION_SENDTO} action 2165 and include the {@code "smsto:"} data scheme. For example:</p> 2166 2167 <pre> 2168 public void composeMmsMessage(String message, Uri attachment) { 2169 Intent intent = new Intent(Intent.ACTION_SEND); 2170 intent.setData(Uri.parse("smsto:")); // This ensures only SMS apps respond 2171 intent.putExtra("sms_body", message); 2172 intent.putExtra(Intent.EXTRA_STREAM, attachment); 2173 if (intent.resolveActivity(getPackageManager()) != null) { 2174 startActivity(intent); 2175 } 2176 } 2177 </pre> 2178 2179 2180 <p><b>Example intent filter:</b></p> 2181 <pre> 2182 <activity ...> 2183 <intent-filter> 2184 <action android:name="android.intent.action.SEND" /> 2185 <data android:type="text/plain" /> 2186 <data android:type="image/*" /> 2187 <category android:name="android.intent.category.DEFAULT" /> 2188 </intent-filter> 2189 </activity> 2190 </pre> 2191 2192 <p class="note"><strong>Note:</strong> If you're developing an SMS/MMS messaging app, you must 2193 implement intent filters for several additional actions in order to be available as the 2194 <em>default SMS app</em> on Android 4.4 and higher. For more information, see the documentation 2195 at {@link android.provider.Telephony}.</p> 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 <h2 id="Browser">Web Browser</h2> 2207 2208 <h3 id="ViewUrl">Load a web URL</h3> 2209 2210 <!-- Google Now box --> 2211 <div class="now-box"> 2212 <div class="now-img-cont"> 2213 <a href="#Now"> 2214 <img src="{@docRoot}guide/components/images/voice-icon.png" class="now-img" 2215 width="30" height="30" alt=""/> 2216 </a> 2217 </div> 2218 <p class="now-title">Google Now</p> 2219 <ul> 2220 <li>"open example.com"</li> 2221 </ul> 2222 </div> 2223 2224 <p>To open a web page, use the {@link android.content.Intent#ACTION_VIEW} action 2225 and specify the web URL in the intent data.</p> 2226 2227 <dl> 2228 <dt><b>Action</b></dt> 2229 <dd>{@link android.content.Intent#ACTION_VIEW}<dd> 2230 2231 <dt><b>Data URI Scheme</b></dt> 2232 <dd><code>http:<em><URL></em></code><br/> 2233 <code>https:<em><URL></em></code></dd> 2234 2235 <dt><b>MIME Type</b></dt> 2236 <dd> 2237 <dl> 2238 <dt><code>"text/plain"</code> 2239 <dt><code>"text/html"</code> 2240 <dt><code>"application/xhtml+xml"</code> 2241 <dt><code>"application/vnd.wap.xhtml+xml"</code> 2242 </dl> 2243 </dd> 2244 </dl> 2245 2246 2247 <p><b>Example intent:</b></p> 2248 <pre> 2249 public void openWebPage(String url) { 2250 Uri webpage = Uri.parse(url); 2251 Intent intent = new Intent(Intent.ACTION_VIEW, webpage); 2252 if (intent.resolveActivity(getPackageManager()) != null) { 2253 startActivity(intent); 2254 } 2255 } 2256 </pre> 2257 2258 2259 <p><b>Example intent filter:</b></p> 2260 <pre> 2261 <activity ...> 2262 <intent-filter> 2263 <action android:name="android.intent.action.VIEW" /> 2264 <!-- Include the host attribute if you want your app to respond 2265 only to URLs with your app's domain. --> 2266 <data android:scheme="http" android:host="www.example.com" /> 2267 <category android:name="android.intent.category.DEFAULT" /> 2268 <!-- The BROWSABLE category is required to get links from web pages. --> 2269 <category android:name="android.intent.category.BROWSABLE" /> 2270 </intent-filter> 2271 </activity> 2272 </pre> 2273 2274 2275 <p class="note"><strong>Tip:</strong> If your Android app provides functionality similar to 2276 your web site, include an intent filter for URLs that point to your web site. Then, 2277 if users have your app installed, links from emails or other web pages pointing to your web site 2278 open your Android app instead of your web page.</p> 2279 2280 2281 2282 2283 2284 2285 2286 <h2 id="AdbIntents">Verify Intents with the Android Debug Bridge</h2> 2287 2288 <p>To verify that your app responds to the intents that you want to support, you can use the 2289 <a href="{@docRoot}tools/help/adb.html"><code>adb</code></a> tool to fire specific intents:</p> 2290 2291 <ol> 2292 <li>Set up an Android device for <a href="{@docRoot}tools/device.html#setting-up">development</a>, 2293 or use a <a href="{@docRoot}tools/devices/emulator.html#avds">virtual device</a>.</li> 2294 <li>Install a version of your app that handles the intents you want to support.</li> 2295 <li>Fire an intent using <code>adb</code>: 2296 <pre class="no-pretty-print"> 2297 adb shell am start -a <ACTION> -t <MIME_TYPE> -d <DATA> \ 2298 -e <EXTRA_NAME> <EXTRA_VALUE> -n <ACTIVITY> 2299 </pre> 2300 <p>For example:</p> 2301 <pre class="no-pretty-print"> 2302 adb shell am start -a android.intent.action.DIAL \ 2303 -d tel:555-5555 -n org.example.MyApp/.MyActivity 2304 </pre> 2305 <li>If you defined the required intent filters, your app should handle the intent.</li> 2306 </ol> 2307 2308 2309 <p>For more information, see 2310 <a href="{@docRoot}tools/help/shell.html#am">ADB Shell Commands</a>.</p> 2311 2312 2313 2314 2315 2316 2317 <h2 id="Now">Intents Fired by Google Now</h2> 2318 2319 <p><a href="http://www.google.com/landing/now/">Google Now</a> recognizes many voice commands 2320 and fires intents for them. As such, users may launch your app with a Google Now voice command 2321 if your app declares the corresponding intent filter. For example, if your app can 2322 <a href="#CreateAlarm">set an alarm</a> and you add the corresponding intent filter to your 2323 manifest file, Google Now lets users choose your app when they request to set an alarm, as 2324 shown in figure 1.</p> 2325 2326 <img src="{@docRoot}guide/components/images/google-action.png" 2327 srcset="{@docRoot}guide/components/images/google-action_2x.png 2x" 2328 width="700" height="241" alt=""/> 2329 <p class="img-caption"><strong>Figure 1.</strong> Google Now lets users choose from installed 2330 apps that support a given action.</p> 2331 2332 <p>Google Now recognizes voice commands for the actions listed in table 1. For more information 2333 about declaring each intent filter, click on the action description.</p> 2334 2335 <p class="table-caption"><strong>Table 1.</strong> Voice commands recognized by Google Now 2336 (Google Search app v3.6).</p> 2337 <table> 2338 <tr> 2339 <th>Category</th> 2340 <th>Details and Examples</th> 2341 <th>Action Name</th> 2342 </tr> 2343 <tr> 2344 <td rowspan="2" style="vertical-align:middle">Alarm</td> 2345 <td> 2346 <p><a href="#CreateAlarm">Set alarm</a></p> 2347 <ul class="now-list"> 2348 <li>"set an alarm for 7 am"</li> 2349 </ul> 2350 </td> 2351 <td>{@link android.provider.AlarmClock#ACTION_SET_ALARM AlarmClock.ACTION_SET_ALARM}</td> 2352 </tr> 2353 <tr> 2354 <td> 2355 <p><a href="#CreateTimer">Set timer</a></p> 2356 <ul class="now-list"> 2357 <li>"set a timer for 5 minutes"</li> 2358 </ul> 2359 </td> 2360 <td>{@link android.provider.AlarmClock#ACTION_SET_TIMER AlarmClock.ACTION_SET_TIMER}</td> 2361 </tr> 2362 <tr> 2363 <td style="vertical-align:middle">Communication</td> 2364 <td> 2365 <p><a href="#DialPhone">Call a number</a></p> 2366 <ul class="now-list"> 2367 <li>"call 555-5555"</li> 2368 <li>"call bob"</li> 2369 <li>"call voicemail"</li> 2370 </ul> 2371 </td> 2372 <td>{@link android.content.Intent#ACTION_CALL Intent.ACTION_CALL}</td> 2373 </tr> 2374 <tr> 2375 <td style="vertical-align:middle">Local</td> 2376 <td> 2377 <p><a href="#CallCar">Book a car</a></p> 2378 <ul class="now-list"> 2379 <li>"call me a car"</li> 2380 <li>"book me a taxi"</li> 2381 </ul> 2382 </td> 2383 <td><a href="{@docRoot}reference/com/google/android/gms/actions/ReserveIntents.html#ACTION_RESERVE_TAXI_RESERVATION"> 2384 <code>ReserveIntents<br/>.ACTION_RESERVE_TAXI_RESERVATION</code></a></td> 2385 </tr> 2386 <tr> 2387 <td rowspan="3" style="vertical-align:middle">Media</td> 2388 <td> 2389 <p><a href="#PlaySearch">Play music from search</a></p> 2390 <ul class="now-list"> 2391 <li>"play michael jackson billie jean"</li> 2392 </ul> 2393 </td> 2394 <td>{@link android.provider.MediaStore#INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH MediaStore<br/>.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH}</td> 2395 </tr> 2396 <tr> 2397 <td> 2398 <p><a href="#CameraStill">Take a picture</a></p> 2399 <ul class="now-list"> 2400 <li>"take a picture"</li> 2401 </ul> 2402 </td> 2403 <td>{@link android.provider.MediaStore#INTENT_ACTION_STILL_IMAGE_CAMERA MediaStore<br/>.INTENT_ACTION_STILL_IMAGE_CAMERA}</td> 2404 </tr> 2405 <tr> 2406 <td> 2407 <p><a href="#CameraVideo">Record a video</a></p> 2408 <ul class="now-list"> 2409 <li>"record a video"</li> 2410 </ul> 2411 </td> 2412 <td>{@link android.provider.MediaStore#INTENT_ACTION_VIDEO_CAMERA MediaStore<br/>.INTENT_ACTION_VIDEO_CAMERA}</td> 2413 </tr> 2414 <tr> 2415 <td style="vertical-align:middle">Search</td> 2416 <td> 2417 <p><a href="#SearchOnApp">Search using a specific app</a></p> 2418 <ul class="now-list"> 2419 <li>"search for cat videos <br/>on myvideoapp"</li> 2420 </ul> 2421 </td> 2422 <td><code>"com.google.android.gms.actions<br/>.SEARCH_ACTION"</code></td> 2423 </tr> 2424 <tr> 2425 <td style="vertical-align:middle">Web browser</td> 2426 <td> 2427 <p><a href="#ViewUrl">Open URL</a></p> 2428 <ul class="now-list"> 2429 <li>"open example.com"</li> 2430 </ul> 2431 </td> 2432 <td>{@link android.content.Intent#ACTION_VIEW Intent.ACTION_VIEW}</td> 2433 </tr> 2434 </table> 2435