summaryrefslogtreecommitdiffstats
path: root/docs/html/training/sharing
diff options
context:
space:
mode:
authorJoe Malin <jmalin@google.com>2013-08-26 14:55:54 -0700
committerJoe Malin <jmalin@google.com>2013-10-11 16:48:18 -0700
commit45edbb701ac44891aa07a403a55ee2393da9b25f (patch)
tree26b1f1d067f6a8a83f41c21873efc40944b49b64 /docs/html/training/sharing
parentc0da3f1d60f99c3188906d429ed38edbdd934f12 (diff)
downloadframeworks_base-45edbb701ac44891aa07a403a55ee2393da9b25f.zip
frameworks_base-45edbb701ac44891aa07a403a55ee2393da9b25f.tar.gz
frameworks_base-45edbb701ac44891aa07a403a55ee2393da9b25f.tar.bz2
DOC CHANGE: FileProvider training class
Change-Id: Idad8840dec02150733f23cfefdeaf152a260f63a
Diffstat (limited to 'docs/html/training/sharing')
-rw-r--r--docs/html/training/sharing/index.jd30
-rw-r--r--docs/html/training/sharing/receive.jd48
-rw-r--r--docs/html/training/sharing/send.jd66
-rw-r--r--docs/html/training/sharing/shareaction.jd58
4 files changed, 107 insertions, 95 deletions
diff --git a/docs/html/training/sharing/index.jd b/docs/html/training/sharing/index.jd
index 2aa22b6..06d42fc 100644
--- a/docs/html/training/sharing/index.jd
+++ b/docs/html/training/sharing/index.jd
@@ -1,4 +1,4 @@
-page.title=Sharing Content
+page.title=Sharing Simple Data
page.tags="intents","share"
trainingnavtop=true
@@ -20,26 +20,26 @@ Intent Filters</a></li>
</div>
</div>
-
+
<p>One of the great things about Android applications is their ability to communicate and
integrate with each other. Why reinvent functionality that isn't core to your application when it
-already exists in another application?</p>
+already exists in another application?</p>
-<p>This class covers some common ways you can send and receive content between
+<p>This class covers some common ways you can send and receive simple data between
applications using {@link android.content.Intent} APIs and the {@link
android.view.ActionProvider} object.</p>
<h2>Lessons</h2>
-
-<dl>
- <dt><b><a href="send.html">Sending Content to Other Apps</a></b></dt>
+
+<dl>
+ <dt><b><a href="send.html">Sending Simple Data to Other Apps</a></b></dt>
<dd>Learn how to set up your application to be able to send text and binary data to other
-applications with intents.</dd>
-
- <dt><b><a href="receive.html">Receiving Content from Other Apps</a></b></dt>
- <dd>Learn how to set up your application to receive text and binary data from intents.</dd>
-
- <dt><b><a href="shareaction.html">Adding an Easy Share Action</a></b></dt>
- <dd>Learn how to add a "share" action item to your action bar.</dd>
-</dl>
+applications with intents.</dd>
+
+ <dt><b><a href="receive.html">Receiving Simple Data from Other Apps</a></b></dt>
+ <dd>Learn how to set up your application to receive text and binary data from intents.</dd>
+
+ <dt><b><a href="shareaction.html">Adding an Easy Share Action</a></b></dt>
+ <dd>Learn how to add a "share" action item to your action bar.</dd>
+</dl>
diff --git a/docs/html/training/sharing/receive.jd b/docs/html/training/sharing/receive.jd
index 7ec3def..8c5f862 100644
--- a/docs/html/training/sharing/receive.jd
+++ b/docs/html/training/sharing/receive.jd
@@ -1,5 +1,5 @@
-page.title=Receiving Content from Other Apps
-parent.title=Sharing Content
+page.title=Receiving Simple Data from Other Apps
+parent.title=Sharing Simple Data
parent.link=index.html
trainingnavtop=true
@@ -30,26 +30,26 @@ Intent Filters</a></li>
</div>
</div>
-<p>Just as your application can send data to other applications, so too can it easily receive data
-from applications. Think about how users interact with your application, and what data types you
-want to receive from other applications. For example, a social networking application would likely
-be interested in receiving text content, like an interesting web URL, from another app. The
+<p>Just as your application can send data to other applications, so too can it easily receive data
+from applications. Think about how users interact with your application, and what data types you
+want to receive from other applications. For example, a social networking application would likely
+be interested in receiving text content, like an interesting web URL, from another app. The
<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.plus">Google+ Android
-application</a>
-accepts both text <em>and</em> single or multiple images. With this app, a user can easily start a
+application</a>
+accepts both text <em>and</em> single or multiple images. With this app, a user can easily start a
new Google+ post with photos from the Android Gallery app.</p>
<h2 id="update-manifest">Update Your Manifest</h2>
-<p>Intent filters inform the system what intents an application component is willing to accept.
-Similar to how you constructed an intent with action {@link android.content.Intent#ACTION_SEND} in
-the <a href="{@docRoot}training/sharing/send.html">Send Content to Other Apps Using Intents</a>
-lesson, you create intent filters in order to be able to receive intents with this action. You
-define an intent filter in your manifest, using the
+<p>Intent filters inform the system what intents an application component is willing to accept.
+Similar to how you constructed an intent with action {@link android.content.Intent#ACTION_SEND} in
+the <a href="{@docRoot}training/sharing/send.html">Sending Simple Data to Other Apps</a>
+lesson, you create intent filters in order to be able to receive intents with this action. You
+define an intent filter in your manifest, using the
<code><a
-href="{@docRoot}guide/components/intents-filters.html#ifs">&lt;intent-filter&gt;</a></code>
-element. For example, if your application handles receiving text content, a single image of any
+href="{@docRoot}guide/components/intents-filters.html#ifs">&lt;intent-filter&gt;</a></code>
+element. For example, if your application handles receiving text content, a single image of any
type, or multiple images of any type, your manifest would look like:</p>
<pre>
@@ -72,24 +72,24 @@ type, or multiple images of any type, your manifest would look like:</p>
&lt;/activity&gt;
</pre>
-<p class="note"><strong>Note:</strong> For more information on intent filters and intent resolution
+<p class="note"><strong>Note:</strong> For more information on intent filters and intent resolution
please read <a href="{@docRoot}guide/components/intents-filters.html#ifs">Intents and Intent
Filters</a></p>
<p>When another application tries to share any of these things by constructing an intent and passing
it to {@link android.content.Context#startActivity(android.content.Intent) startActivity()}, your
-application will be listed as an option in the intent chooser. If the user selects your application,
-the corresponding activity (<code>.ui.MyActivity</code> in the example above) will be started. It
+application will be listed as an option in the intent chooser. If the user selects your application,
+the corresponding activity (<code>.ui.MyActivity</code> in the example above) will be started. It
is then up to you to handle the content appropriately within your code and UI.</p>
<h2 id="handling-content">Handle the Incoming Content</h2>
<p>To handle the content delivered by an {@link android.content.Intent}, start by calling {@link
-android.content.Intent#getIntent(String) getIntent()}
-to get {@link android.content.Intent} object. Once you have the object, you can examine its
-contents to determine what to do next. Keep in mind that if this activity can be started from other
-parts of the system, such as the launcher, then you will need to take this into consideration when
+android.content.Intent#getIntent(String) getIntent()}
+to get {@link android.content.Intent} object. Once you have the object, you can examine its
+contents to determine what to do next. Keep in mind that if this activity can be started from other
+parts of the system, such as the launcher, then you will need to take this into consideration when
examining the intent.</p>
<pre>
@@ -143,7 +143,7 @@ know what some other application may send you. For example, the wrong MIME type
image being sent might be extremely large. Also, remember to process binary data in a separate
thread rather than the main ("UI") thread.</p>
-<p>Updating the UI can be as simple as populating an {@link android.widget.EditText}, or it can
-be more complicated like applying an interesting photo filter to an image. It's really specific
+<p>Updating the UI can be as simple as populating an {@link android.widget.EditText}, or it can
+be more complicated like applying an interesting photo filter to an image. It's really specific
to your application what happens next.</p>
diff --git a/docs/html/training/sharing/send.jd b/docs/html/training/sharing/send.jd
index ed9e12e..f5da68f 100644
--- a/docs/html/training/sharing/send.jd
+++ b/docs/html/training/sharing/send.jd
@@ -1,9 +1,9 @@
-page.title=Sending Content to Other Apps
-parent.title=Sharing Content
+page.title=Sending Simple Data to Other Apps
+parent.title=Sharing Simple Data
parent.link=index.html
trainingnavtop=true
-next.title=Receiving Content from Other Apps
+next.title=Receiving Simple Data from Other Apps
next.link=receive.html
@jd:body
@@ -29,22 +29,22 @@ Intent Filters</a></li>
</div>
</div>
-<p>When you construct an intent, you must specify the action you want the intent to "trigger."
-Android defines several actions, including {@link android.content.Intent#ACTION_SEND} which, as
-you can probably guess, indicates that the intent is sending data from one activity to another,
-even across process boundaries. To send data to another activity, all you need to do is specify
-the data and its type, the system will identify compatible receiving activities and display them
-to the user (if there are multiple options) or immediately start the activity (if there is only
-one option). Similarly, you can advertise the data types that your activities support receiving
+<p>When you construct an intent, you must specify the action you want the intent to "trigger."
+Android defines several actions, including {@link android.content.Intent#ACTION_SEND} which, as
+you can probably guess, indicates that the intent is sending data from one activity to another,
+even across process boundaries. To send data to another activity, all you need to do is specify
+the data and its type, the system will identify compatible receiving activities and display them
+to the user (if there are multiple options) or immediately start the activity (if there is only
+one option). Similarly, you can advertise the data types that your activities support receiving
from other applications by specifying them in your manifest.</p>
-<p>Sending and receiving data between applications with intents is most commonly used for social
-sharing of content. Intents allow users to share information quickly and easily, using their
+<p>Sending and receiving data between applications with intents is most commonly used for social
+sharing of content. Intents allow users to share information quickly and easily, using their
favorite applications.</p>
-<p><strong>Note:</strong> The best way to add a share action item to an
-{@link android.app.ActionBar} is to use {@link android.widget.ShareActionProvider}, which became
-available in API level 14. {@link android.widget.ShareActionProvider} is discussed in the lesson
+<p><strong>Note:</strong> The best way to add a share action item to an
+{@link android.app.ActionBar} is to use {@link android.widget.ShareActionProvider}, which became
+available in API level 14. {@link android.widget.ShareActionProvider} is discussed in the lesson
about <a href="shareaction.html">Adding an Easy Share Action</a>.</p>
@@ -58,10 +58,10 @@ on a handset.
</p>
</div>
-<p>The most straightforward and common use of the {@link android.content.Intent#ACTION_SEND}
-action is sending text content from one activity to another. For example, the built-in Browser
-app can share the URL of the currently-displayed page as text with any application. This is useful
-for sharing an article or website with friends via email or social networking. Here is the code to
+<p>The most straightforward and common use of the {@link android.content.Intent#ACTION_SEND}
+action is sending text content from one activity to another. For example, the built-in Browser
+app can share the URL of the currently-displayed page as text with any application. This is useful
+for sharing an article or website with friends via email or social networking. Here is the code to
implement this type of sharing:</p>
<pre>
@@ -72,12 +72,12 @@ sendIntent.setType(&quot;text/plain&quot;);
startActivity(sendIntent);
</pre>
-<p>If there's an installed application with a filter that matches
-{@link android.content.Intent#ACTION_SEND} and MIME type text/plain, the Android system will run
-it; if more than one application matches, the system displays a disambiguation dialog (a "chooser")
-that allows the user to choose an app. If you call
+<p>If there's an installed application with a filter that matches
+{@link android.content.Intent#ACTION_SEND} and MIME type text/plain, the Android system will run
+it; if more than one application matches, the system displays a disambiguation dialog (a "chooser")
+that allows the user to choose an app. If you call
{@link android.content.Intent#createChooser(android.content.Intent, CharSequence)
-Intent.createChooser()}
+Intent.createChooser()}
for the intent, Android will <strong>always</strong> display the chooser. This has some
advantages:</p>
@@ -100,17 +100,17 @@ startActivity(<strong>Intent.createChooser(sendIntent, getResources().getText(R.
<p>The resulting dialog is shown in figure 1.</p>
-<p>Optionally, you can set some standard extras for the intent:
-{@link android.content.Intent#EXTRA_EMAIL}, {@link android.content.Intent#EXTRA_CC},
-{@link android.content.Intent#EXTRA_BCC}, {@link android.content.Intent#EXTRA_SUBJECT}. However,
-if the receiving application is not designed to use them, nothing will happen. You can use
-custom extras as well, but there's no effect unless the receiving application understands them.
+<p>Optionally, you can set some standard extras for the intent:
+{@link android.content.Intent#EXTRA_EMAIL}, {@link android.content.Intent#EXTRA_CC},
+{@link android.content.Intent#EXTRA_BCC}, {@link android.content.Intent#EXTRA_SUBJECT}. However,
+if the receiving application is not designed to use them, nothing will happen. You can use
+custom extras as well, but there's no effect unless the receiving application understands them.
Typically, you'd use custom extras defined by the receiving application itself.</p>
-<p class="note"><strong>Note:</strong> Some e-mail applications, such as Gmail, expect a
-{@link java.lang.String String[]} for extras like {@link android.content.Intent#EXTRA_EMAIL} and
-{@link android.content.Intent#EXTRA_CC}, use
-{@link android.content.Intent#putExtra(String,String[]) putExtra(String, String[])} to add these
+<p class="note"><strong>Note:</strong> Some e-mail applications, such as Gmail, expect a
+{@link java.lang.String String[]} for extras like {@link android.content.Intent#EXTRA_EMAIL} and
+{@link android.content.Intent#EXTRA_CC}, use
+{@link android.content.Intent#putExtra(String,String[]) putExtra(String, String[])} to add these
to your intent.</p>
diff --git a/docs/html/training/sharing/shareaction.jd b/docs/html/training/sharing/shareaction.jd
index 873f614..ee811da 100644
--- a/docs/html/training/sharing/shareaction.jd
+++ b/docs/html/training/sharing/shareaction.jd
@@ -3,7 +3,7 @@ parent.title=Sharing Content
parent.link=index.html
trainingnavtop=true
-previous.title=Receiving Content from Other Apps
+previous.title=Receiving Simple Data from Other Apps
previous.link=receive.html
@jd:body
@@ -28,7 +28,7 @@ previous.link=receive.html
</div>
-<p>Implementing an effective and user friendly share action in your {@link android.app.ActionBar}
+<p>Implementing an effective and user friendly share action in your {@link android.app.ActionBar}
is made even easier with the introduction of {@link android.view.ActionProvider} in Android 4.0
(API Level 14). An {@link android.view.ActionProvider}, once attached to a menu item in the action
bar, handles both the appearance and behavior of that item. In the case of {@link
@@ -47,36 +47,48 @@ starting with API Level 14 and higher.</p>
<h2 id="update-menus">Update Menu Declarations</h2>
-<p>To get started with {@link android.widget.ShareActionProvider ShareActionProviders}, define the <code>android:actionProviderClass</code> attribute for the corresponding <code>&lt;item&gt;</code> in your <a href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a> file:</p>
+<p>
+ To get started with {@link android.widget.ShareActionProvider ShareActionProviders},
+ define the <code>android:actionProviderClass</code> attribute for the corresponding
+ <code>&lt;item&gt;</code> in your <a href="{@docRoot}guide/topics/resources/menu-resource.html"
+ >menu resource</a> file:</p>
<pre>
&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
- &lt;item android:id=&quot;@+id/menu_item_share&quot;
- android:showAsAction=&quot;ifRoom&quot;
- android:title=&quot;Share&quot;
- <strong>android:actionProviderClass=&quot;android.widget.ShareActionProvider&quot;</strong> /&gt;
+ &lt;item
+ android:id=&quot;@+id/menu_item_share&quot;
+ android:showAsAction=&quot;ifRoom&quot;
+ android:title=&quot;Share&quot;
+ <b>android:actionProviderClass=
+ "android.widget.ShareActionProvider"</b> /&gt;
...
&lt;/menu&gt;
</pre>
-<p>This delegates responsibility for the item's appearance and function to
-{@link android.widget.ShareActionProvider}. However, you will need to tell the provider what you
-would like to share.</p>
+<p>
+ This delegates responsibility for the item's appearance and function to
+ {@link android.widget.ShareActionProvider}. However, you will need to tell the provider what you
+ would like to share.
+</p>
<h2 id="set-share-intent">Set the Share Intent</h2>
-<p>In order for {@link android.widget.ShareActionProvider} to function, you must provide it a share
-intent. This share intent should be the same as described in the <a
-href="{@docRoot}training/sharing/send.html">Sending Content to Other Apps</a>
-lesson, with action {@link android.content.Intent#ACTION_SEND} and additional data set via extras
-like {@link android.content.Intent#EXTRA_TEXT} and {@link android.content.Intent#EXTRA_STREAM}. To
-assign a share intent, first find the corresponding {@link android.view.MenuItem} while inflating
-your menu resource in your {@link android.app.Activity} or {@link android.app.Fragment}. Next, call
-{@link android.view.MenuItem#getActionProvider() MenuItem.getActionProvider()} to retreive an
-instance of {@link android.widget.ShareActionProvider}. Use {@link
-android.widget.ShareActionProvider#setShareIntent(android.content.Intent) setShareIntent()} to
-update the share intent associated with that action item. Here's an example:</p>
+<p>
+ In order for {@link android.widget.ShareActionProvider} to function, you must provide it a share
+ intent. This share intent should be the same as described in the
+ <a href="{@docRoot}training/sharing/send.html">Sending Simple Data to Other Apps</a> lesson,
+ with action {@link android.content.Intent#ACTION_SEND} and additional data set via extras
+ like {@link android.content.Intent#EXTRA_TEXT} and {@link android.content.Intent#EXTRA_STREAM}.
+ To assign a share intent, first find the corresponding {@link android.view.MenuItem} while
+ inflating your menu resource in your {@link android.app.Activity} or
+ {@link android.app.Fragment}. Next, call {@link android.view.MenuItem#getActionProvider
+ MenuItem.getActionProvider()} to retrieve an instance of
+ {@link android.widget.ShareActionProvider}. Use
+ {@link android.widget.ShareActionProvider#setShareIntent(android.content.Intent)
+ setShareIntent()} to update the share intent associated with that action item. Here's an
+ example:
+</p>
<pre>
private ShareActionProvider mShareActionProvider;
@@ -105,8 +117,8 @@ private void setShareIntent(Intent shareIntent) {
}
</pre>
-<p>You may only need to set the share intent once during the creation of your menus, or you may
-want to set it and then update it as the UI changes. For example, when you view photos full screen
+<p>You may only need to set the share intent once during the creation of your menus, or you may
+want to set it and then update it as the UI changes. For example, when you view photos full screen
in the Gallery app, the sharing intent changes as you flip between photos.</p>
<p>For further discussion about the {@link android.widget.ShareActionProvider} object, see the <a