diff --git a/docs/html/guide/components/images/google-action.png b/docs/html/guide/components/images/google-action.png new file mode 100644 index 0000000000000..f716d3d19f59b Binary files /dev/null and b/docs/html/guide/components/images/google-action.png differ diff --git a/docs/html/guide/components/images/google-action_2x.png b/docs/html/guide/components/images/google-action_2x.png new file mode 100644 index 0000000000000..81a349d698555 Binary files /dev/null and b/docs/html/guide/components/images/google-action_2x.png differ diff --git a/docs/html/guide/components/images/voice-icon.png b/docs/html/guide/components/images/voice-icon.png new file mode 100644 index 0000000000000..b2e9e85c2a000 Binary files /dev/null and b/docs/html/guide/components/images/voice-icon.png differ diff --git a/docs/html/guide/components/intents-common.jd b/docs/html/guide/components/intents-common.jd index af9456de47f7e..5954645430222 100644 --- a/docs/html/guide/components/intents-common.jd +++ b/docs/html/guide/components/intents-common.jd @@ -26,6 +26,8 @@ page.tags="IntentFilter"
An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") @@ -121,12 +179,17 @@ it's safe to call {@link android.content.Context#startActivity startActivity()}. null, you should not use the intent and, if possible, you should disable the feature that invokes the intent.
-If you're not familiar with how to create intents or intent filters, you should first read Intents and Intent Filters.
+To learn how to fire the intents listed on this page from your development host, see +Verify Intents with the Android Debug Bridge.
+Google Now fires some of the intents listed +on this page in response to voice commands. For more information, see +Intents Fired by Google Now.
@@ -138,11 +201,25 @@ the intent.To create a new alarm, use the {@link android.provider.AlarmClock#ACTION_SET_ALARM} action and specify alarm details such as the time and message using extras defined below.
Note: Only the hour, minutes, and message extras are available -since Android 2.3 (API level 9). The other extras were added in later versions of the platform.
+in Android 2.3 (API level 9) and higher. The other extras were added in later versions of the +platform.To create a countdown timer, use the {@link android.provider.AlarmClock#ACTION_SET_TIMER} action and specify timer details such as the duration using extras defined below.
@@ -509,6 +599,116 @@ in an extra named"data".
+To open a camera app in still image mode, use the {@link +android.provider.MediaStore#INTENT_ACTION_STILL_IMAGE_CAMERA} action.
+ +Example intent:
+
+public void capturePhoto() {
+ Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent);
+ }
+}
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + +
To open a camera app in video mode, use the {@link +android.provider.MediaStore#INTENT_ACTION_VIDEO_CAMERA} action.
+ +Example intent:
+
+public void capturePhoto() {
+ Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent);
+ }
+}
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.media.action.VIDEO_CAMERA" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + +
There are primarily two ways to initially retrieve the contact's URI:
There are primarily two ways to initially retrieve the contact URI:
To compose an email, use one of the below actions based on whether you'll include attachments, and include email details such as the recipient and subject using the extra keys listed below.
@@ -901,6 +1100,73 @@ public void composeEmail(String[] addresses, String subject) { +To take a note, use the {@link android.content.Intent#ACTION_SEND} action and specify the +text for the note with the {@link android.content.Intent#EXTRA_TEXT}.
+ +com.google.android.voicesearch.SELF_NOTEExample intent:
+
+public void takeNote(String content) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_TEXT, content);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.intent.action.SEND" /> + <category android:name="com.google.android.voicesearch.SELF_NOTE" /> + </intent-filter> +</activity> ++ + @@ -1153,6 +1419,410 @@ Framework guide. +
To track a bike ride, use the "vnd.google.fitness.TRACK" action with the
+"vnd.google.fitness.activity/biking" MIME type and set the "actionStatus"
+extra to "ActiveActionStatus" when starting and to "CompletedActionStatus"
+when stopping.
"vnd.google.fitness.TRACK""vnd.google.fitness.activity/biking""actionStatus""ActiveActionStatus" when starting and
+ "CompletedActionStatus" when stopping.Example intent:
+
+public void startBikeRide() {
+ Intent intent = new Intent("vnd.google.fitness.TRACK")
+ .setType("vnd.google.fitness.activity/biking")
+ .putExtra("actionStatus", "ActiveActionStatus");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="vnd.google.fitness.TRACK" /> + <data android:mimeType="vnd.google.fitness.activity/biking" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + +
To track a run, use the "vnd.google.fitness.TRACK" action with the
+"vnd.google.fitness.activity/running" MIME type and set the "actionStatus"
+extra to "ActiveActionStatus" when starting and to "CompletedActionStatus"
+when stopping.
"vnd.google.fitness.TRACK""vnd.google.fitness.activity/running""actionStatus""ActiveActionStatus" when starting and
+ "CompletedActionStatus" when stopping.Example intent:
+
+public void startRun() {
+ Intent intent = new Intent("vnd.google.fitness.TRACK")
+ .setType("vnd.google.fitness.activity/running")
+ .putExtra("actionStatus", "ActiveActionStatus");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="vnd.google.fitness.TRACK" /> + <data android:mimeType="vnd.google.fitness.activity/running" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + +
To track a workout, use the "vnd.google.fitness.TRACK" action with the
+"vnd.google.fitness.activity/other" MIME type and set the "actionStatus"
+extra to "ActiveActionStatus" when starting and to "CompletedActionStatus"
+when stopping.
"vnd.google.fitness.TRACK""vnd.google.fitness.activity/other""actionStatus""ActiveActionStatus" when starting and
+ "CompletedActionStatus" when stopping.Example intent:
+
+public void startWorkout() {
+ Intent intent = new Intent("vnd.google.fitness.TRACK")
+ .setType("vnd.google.fitness.activity/other")
+ .putExtra("actionStatus", "ActiveActionStatus");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="vnd.google.fitness.TRACK" /> + <data android:mimeType="vnd.google.fitness.activity/other" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + +
To show the user's heart rate, use the "vnd.google.fitness.VIEW" action with the
+"vnd.google.fitness.data_type MIME type.
/com.google.heart_rate.bpm"
"vnd.google.fitness.VIEW""vnd.google.fitness.data_type/com.google.heart_rate.bpm"Example intent:
+
+public void showHR() {
+ Intent intent = new Intent("vnd.google.fitness.VIEW")
+ .setType("vnd.google.fitness.data_type/com.google.heart_rate.bpm");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="vnd.google.fitness.VIEW" /> + <data android:mimeType="vnd.google.fitness.data_type/com.google.heart_rate.bpm" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + +
To show the user's step count, use the "vnd.google.fitness.VIEW" action with the
+"vnd.google.fitness.data_type MIME type.
/com.google.step_count.cumulative"
"vnd.google.fitness.VIEW""vnd.google.fitness.data_type/com.google.step_count.cumulative"Example intent:
+
+public void showStepCount() {
+ Intent intent = new Intent("vnd.google.fitness.VIEW")
+ .setType("vnd.google.fitness.data_type/com.google.step_count.cumulative");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="vnd.google.fitness.VIEW" /> + <data android:mimeType="vnd.google.fitness.data_type/com.google.step_count.cumulative" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + + + + +
To call a taxi, use the
+ACTION_RESERVE_TAXI_RESERVATION
+action.
Note: Apps must ask for confirmation from the user +before completing the action.
+ +ACTION_RESERVE_TAXI_RESERVATIONExample intent:
+
+public void callCar() {
+ Intent intent = new Intent(ReserveIntents.ACTION_RESERVE_TAXI_RESERVATION);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + @@ -1290,6 +1960,19 @@ public void playMedia(Uri file) {
To play music based on a search query, use the {@link android.provider.MediaStore#INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH} intent. An app may fire this intent in response to the user's voice command to play music. The receiving app for this @@ -1523,13 +2206,49 @@ android.content.Intent#ACTION_DIAL} action and specify a phone number using the URI scheme defined below. When the phone app opens, it displays the phone number but the user must press the Call button to begin the phone call.
+ + + +To place a phone call directly, use the {@link android.content.Intent#ACTION_CALL} action +and specify a phone number using the URI scheme defined below. When the phone app opens, it +begins the phone call; the user does not need to press the Call button.
+ +The {@link android.content.Intent#ACTION_CALL} action requires that you add the
+CALL_PHONE permission to your manifest file:
+<uses-permission android:name="android.permission.CALL_PHONE" /> +
CALL_PHONE permission)To open a web page, use the {@link android.content.Intent#ACTION_VIEW} action and specify the web URL in the intent data.
@@ -1833,3 +2562,210 @@ public void searchWeb(String query) { + + + + +To verify that your app responds to the intents that you want to support, you can use the
+adb tool to fire specific intents:
adb:
++adb shell am start -a <ACTION> -t <MIME_TYPE> -d <DATA> \ + -e <EXTRA_NAME> <EXTRA_VALUE> -n <ACTIVITY> ++
For example:
++adb shell am start -a android.intent.action.DIAL \ + -d tel:555-5555 -n org.example.MyApp/.MyActivity ++
For more information, see +Using activity manager (am).
+ + + + + + +Google Now recognizes many voice commands +and fires intents for them. As such, users may launch your app with a Google Now voice command +if your app declares the corresponding intent filter. For example, if your app can +set an alarm and you add the corresponding intent filter to your +manifest file, Google Now lets users choose your app when they request to set an alarm, as +shown in figure 1.
+ +
+Figure 1. Google Now lets users choose from installed +apps that support a given action.
+ +Google Now recognizes voice commands for the actions listed in table 1. For more information +about declaring each intent filter, click on the action description.
+ +Table 1. Voice commands recognized by Google Now +(Google Search app v3.6).
+| Category | +Details and Examples | +Action Name | +
|---|---|---|
| Alarm | +
+
+
|
+ {@link android.provider.AlarmClock#ACTION_SET_ALARM AlarmClock.ACTION_SET_ALARM} | +
+
+
|
+ {@link android.provider.AlarmClock#ACTION_SET_TIMER AlarmClock.ACTION_SET_TIMER} | +|
| Communication | +
+
+
|
+ {@link android.content.Intent#ACTION_CALL Intent.ACTION_CALL} | +
+
+
|
+ {@link android.content.Intent#ACTION_SEND Intent.ACTION_SEND} | +|
| Fitness | +
+
+
|
+ "vnd.google.fitness.TRACK" |
+
+
+
|
+ "vnd.google.fitness.TRACK" |
+|
+
+
|
+ "vnd.google.fitness.TRACK" |
+|
+
+
|
+ "vnd.google.fitness.VIEW" |
+|
+
+
|
+ "vnd.google.fitness.VIEW" |
+|
| Local | +
+
+
|
+
+ ReserveIntents |
+
| Media | +
+
+
|
+ {@link android.provider.MediaStore#INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH MediaStore .INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH} |
+
+
+
|
+ {@link android.provider.MediaStore#INTENT_ACTION_STILL_IMAGE_CAMERA MediaStore .INTENT_ACTION_STILL_IMAGE_CAMERA} |
+|
+
+
|
+ {@link android.provider.MediaStore#INTENT_ACTION_VIDEO_CAMERA MediaStore .INTENT_ACTION_VIDEO_CAMERA} |
+|
| Web browser | +
+
+
|
+ {@link android.content.Intent#ACTION_VIEW Intent.ACTION_VIEW} | +