diff options
Diffstat (limited to 'docs/html/guide')
| -rw-r--r-- | docs/html/guide/faq/security.jd | 4 | ||||
| -rw-r--r-- | docs/html/guide/google/gcm/gcm.jd | 6 | ||||
| -rw-r--r-- | docs/html/guide/practices/security.jd | 4 | ||||
| -rw-r--r-- | docs/html/guide/topics/appwidgets/index.jd | 87 | ||||
| -rw-r--r-- | docs/html/guide/topics/manifest/activity-element.jd | 10 | ||||
| -rw-r--r-- | docs/html/guide/topics/manifest/application-element.jd | 18 | ||||
| -rw-r--r-- | docs/html/guide/topics/manifest/permission-element.jd | 2 | ||||
| -rw-r--r-- | docs/html/guide/topics/manifest/provider-element.jd | 161 | ||||
| -rw-r--r-- | docs/html/guide/topics/manifest/uses-feature-element.jd | 8 | ||||
| -rw-r--r-- | docs/html/guide/topics/providers/content-provider-basics.jd | 147 | ||||
| -rw-r--r-- | docs/html/guide/topics/resources/providing-resources.jd | 33 | ||||
| -rw-r--r-- | docs/html/guide/topics/resources/string-resource.jd | 24 |
12 files changed, 336 insertions, 168 deletions
diff --git a/docs/html/guide/faq/security.jd b/docs/html/guide/faq/security.jd index 52ee0d9..a6e07c8 100644 --- a/docs/html/guide/faq/security.jd +++ b/docs/html/guide/faq/security.jd @@ -57,9 +57,7 @@ key</a>.</p> <p>We appreciate researchers practicing responsible disclosure by emailing us with a detailed summary of the issue and keeping the issue confidential while users are at risk. In return, we will make sure to keep the researcher informed -of our progress in issuing a fix and will properly credit the reporter(s) when -we provide the patch. We will always move swiftly to mitigate or fix an -externally-reported flaw and provide updates to users. </p> +of our progress in issuing a fix. </p> <a name="informed" id="informed"></a><h2>How can I stay informed about Android security?</h2> diff --git a/docs/html/guide/google/gcm/gcm.jd b/docs/html/guide/google/gcm/gcm.jd index 5d3ea56..a402e8e 100644 --- a/docs/html/guide/google/gcm/gcm.jd +++ b/docs/html/guide/google/gcm/gcm.jd @@ -659,8 +659,10 @@ message sent by the application server. See <a href="adv.html#collapsible">Advan <td><code>data</code></td> <td>A JSON object whose fields represents the key-value pairs of the message's payload data. If present, the payload data it will be included in the Intent as application data, with the key being the extra's name. For instance, <code>"data":{"score":"3x1"}</code> would result in an intent extra named <code>score</code> whose value is the string <code>3x1</code>. + There is no limit on the number of key/value pairs, though there is a limit on the total size of the message (4kb). The values could be any JSON object, but we recommend using strings, since the values will be converted to strings in the GCM server anyway. If you want to include objects or other non-string data types (such as integers or booleans), you have to do the conversion to string yourself. Also note that the key cannot be a reserved word (<code>from</code> or any word starting with <code>google.</code>). To complicate things slightly, there are some reserved words (such as <code>collapse_key</code>) that are technically allowed in payload data. However, if the request also contains the word, the value in the request will overwrite the value in the payload data. Hence using words that are defined as field names in this table is not recommended, even in cases where they are technically allowed. Optional.</td> + </tr> <tr> <td><code>delay_while_idle</code></td> @@ -701,8 +703,10 @@ sent. Optional. The default value is <code>false</code>, and must be a JSON bool </tr> <tr> <td><code>data.<key></code></td> + <td>Payload data, expressed as parameters prefixed with <code>data.</code> and suffixed as the key. For instance, a parameter of <code>data.score=3x1</code> would result in an intent extra named <code>score</code> whose value is the string <code>3x1</code>. There is no limit on the number of key/value parameters, though there is a limit on the total size of the message. Also note that the key cannot be a reserved word (<code>from</code> or any word starting with <code>google.</code>). To complicate things slightly, there are some reserved words (such as <code>collapse_key</code>) that are technically allowed in payload data. However, if the request also contains the word, the value in the request will overwrite the value in the payload data. Hence using words that are defined as field names in this table is not recommended, even in cases where they are technically allowed. Optional.</td> + </tr> <tr> <td><code>delay_while_idle</code></td> @@ -912,13 +916,11 @@ Happens when the error code is <code>InvalidDataKey</code>.</dd> </ul> Check that the token you're sending inside the <code>Authorization</code> header is the correct API key associated with your project. You can check the validity of your API key by running the following command:<br/> - <pre># api_key=YOUR_API_KEY # curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"</pre> - If you receive a 401 HTTP status code, your API key is not valid. Otherwise you should see something like this:<br/> <pre> diff --git a/docs/html/guide/practices/security.jd b/docs/html/guide/practices/security.jd index ce59a9d..36eeff8 100644 --- a/docs/html/guide/practices/security.jd +++ b/docs/html/guide/practices/security.jd @@ -1,11 +1,11 @@ -page.title=Designing for Security +page.title=Designing for Security @jd:body <div id="qv-wrapper"> <div id="qv"> <h2>In this document</h2> <ol> -<li><a href="#Dalvik">Using Davlik Code</a></li> +<li><a href="#Dalvik">Using Dalvik Code</a></li> <li><a href="#Native">Using Native Code</a></li> <li><a href="#Data">Storing Data</a></li> <li><a href="#IPC">Using IPC</a></li> diff --git a/docs/html/guide/topics/appwidgets/index.jd b/docs/html/guide/topics/appwidgets/index.jd index 7e031d9..9e8a825 100644 --- a/docs/html/guide/topics/appwidgets/index.jd +++ b/docs/html/guide/topics/appwidgets/index.jd @@ -2,7 +2,7 @@ page.title=App Widgets @jd:body <div id="qv-wrapper"> - <div id="qv"> + <div id="qv">re <h2>Quickview</h2> <ul> <li>App Widgets provide users access to some of your application features @@ -33,6 +33,11 @@ from </ol> </li> <li><a href="#preview">Setting a Preview Image</a></li> + <li><a href="#lockscreen">Enabling App Widgets on the Lockscreen + <ol> + <li><a href="#lockscreen-sizing">Sizing guidelines</li> + </ol> + </li> <li><a href="#collections">Using App Widgets with Collections</a> <ol> <li><a href="#collection_sample">Sample application</a></li> @@ -179,7 +184,9 @@ folder.</p> android:previewImage="@drawable/preview" android:initialLayout="@layout/example_appwidget" android:configure="com.example.android.ExampleAppWidgetConfigure" - android:resizeMode="horizontal|vertical"> + android:resizeMode="horizontal|vertical" + android:widgetCategory="home_screen|keyguard" + android:initialKeyguardLayout="@layout/example_keyguard"> </appwidget-provider> </pre> @@ -274,7 +281,21 @@ widget to show its resize handles, then drag the horizontal and/or vertical handles to change the size on the layout grid. Values for the <code>resizeMode</code> attribute include "horizontal", "vertical", and "none". To declare a widget as resizeable horizontally and vertically, supply the value -"horizontal|vertical". Introduced in Android 3.1.</li> </ul> +"horizontal|vertical". Introduced in Android 3.1.</li> + +<li>The <code>widgetCategory</code> attribute declares whether your App Widget can be displayed on the home screen, +the lock screen (keyguard), or both. Values for this attribute include "home_screen" and "keyguard". A widget that +is displayed on both needs to ensure that it follows the design guidelines for both widget classes. For more +information, see <a href="#lockscreen">Enabling App Widgets on the Lockscreen</a>. The default value is "home_screen". Introduced in Android 4.2. +</li> + +<li>The <code>initialKeyguardLayout</code> attribute points to the layout resource +that defines the lock screen App Widget layout. This works the same way as the +{@link android.appwidget.AppWidgetProviderInfo#initialLayout android:initialLayout}, +in that it provides a layout that can appear immediately until your app widget is initialized and able to update +the layout. Introduced in Android 4.2.</li> + +</ul> <p>See the {@link android.appwidget.AppWidgetProviderInfo} class for more information on the @@ -731,6 +752,66 @@ preview image, launch this application, select the app widget for your application and set it up how you'd like your preview image to appear, then save it and place it in your application's drawable resources.</p> +<h2 id="lockscreen">Enabling App Widgets on the Lockscreen</h2> + +<p>Android 4.2 introduces the ability for users to add widgets to the lock screen. To indicate that your app widget is available for use on the lock screen, declare the {@link android.appwidget.AppWidgetProviderInfo#widgetCategory android:widgetCategory} attribute in the XML file that specifies your {@link android.appwidget.AppWidgetProviderInfo}. This attribute supports two values: "home_screen" and "keyguard". An app widget can declare support for one or both.</p> + +<p>By default, every app widget supports placement on the Home screen, so "home_screen" is the default value for the +{@link android.appwidget.AppWidgetProviderInfo#widgetCategory android:widgetCategory} attribute. If you want your app widget to be available for the lock screen, add the "keyguard" value:</p> +<pre> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + ... + android:widgetCategory="keyguard|home_screen"> +</appwidget-provider> +</pre> + +<p>If you declare a widget to be displayable on both keyguard (lockscreen) and home, it's likely that you'll want to customize the widget depending on where it is displayed. For example, you might create a separate layout file for keyguard vs. home. The next step is to detect the widget category at runtime and respond accordingly. + +You can detect whether your widget is on the lockscreen or home screen by calling +{@link android.appwidget.AppWidgetManager#getAppWidgetOptions getAppWidgetOptions()} +to get the widget's options as a {@link android.os.Bundle}. The returned bundle will include the key +{@link android.appwidget.AppWidgetManager#OPTION_APPWIDGET_HOST_CATEGORY}, whose value will be one of {@link android.appwidget.AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or +{@link android.appwidget.AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}. This value is determined by the host into which the widget is bound. In the {@link android.appwidget.AppWidgetProvider}, you can then check the widget's category, for example:</p> + +<pre> +AppWidgetManager appWidgetManager; +int widgetId; +Bundle myOptions = appWidgetManager.getAppWidgetOptions (widgetId); + +// Get the value of OPTION_APPWIDGET_HOST_CATEGORY +int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1); + +// If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget +boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD; +</pre> + +<p>Once you know the widget's category, you can optionally load a different base layout, set different properties, and so on. For example:</p> + +<pre> +int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout; +</pre> + + +<p>You should also specify an initial layout for your app widget when on the lock screen with the +{@link android.appwidget.AppWidgetProviderInfo#initialKeyguardLayout android:initialKeyguardLayout} attribute. This works the same way as the +{@link android.appwidget.AppWidgetProviderInfo#initialLayout android:initialLayout}, in that it provides a layout that can appear immediately until your app widget is initialized and able to update the layout.</p> + +<h3 id="lockscreen-sizing">Sizing guidelines</h3> + +<p>When a widget is hosted on the lockscreen, the framework ignores the {@code minWidth}, {@code minHeight}, {@code minResizeWidth}, and {@code minResizeHeight} fields. If a widget is also a home screen widget, these parameters are still needed as they're still used on home, but they will be ignored for purposes of the lockscreen.</p> + +<p>The width of a lockscreen widget always fills the provided space. For the height of a lockscreen widget, you have the following options:</p> + +<ul> + <li>If the widget does not mark itself as vertically resizable ({@code android:resizeMode="vertical"}), then the widget height will always be "small": + <ul> + <li>On a phone in portrait mode, "small" is defined as the space remaining when an unlock UI is being displayed.</li> + <li>On tablets and landscape phones, "small" is set on a per-device basis.</li> + </ul> + </li> + <li>If the widget marks itself as vertically resizable, then the widget height shows up as "small" on portrait phones displaying an unlock UI. In all other cases, the widget sizes to fill the available height.</li> +</ul> + <h2 id="collections">Using App Widgets with Collections</h2> <p>Android 3.0 introduces App Widgets with collections. These kinds of App diff --git a/docs/html/guide/topics/manifest/activity-element.jd b/docs/html/guide/topics/manifest/activity-element.jd index 844be11..2aedaec 100644 --- a/docs/html/guide/topics/manifest/activity-element.jd +++ b/docs/html/guide/topics/manifest/activity-element.jd @@ -218,7 +218,8 @@ separated by '{@code |}' — for example, "{@code locale|navigation|orientat <td>"{@code uiMode}"</td> <td>The user interface mode has changed — this can be caused when the user places the device into a desk/car dock or when the the night mode changes. See {@link -android.app.UiModeManager}. <em>Introduced in API Level 8</em>.</td> +android.app.UiModeManager}. + <em>Added in API level 8</em>.</td> </tr><tr> <td>"{@code orientation}"</td> <td>The screen orientation has changed — the user has rotated the device. @@ -246,7 +247,12 @@ smallestWidth configuration</a>. However, if your application targets API level your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device). <p><em>Added in API level 13.</em></p></td> - </tr> + </tr><tr> + <td>"{@code layoutDirection}"</td> + <td>The layout direction has changed. For example, changing from left-to-right (LTR) + to right-to-left (RTL). + <em>Added in API level 17.</em></td> + </tr> </table> <p> diff --git a/docs/html/guide/topics/manifest/application-element.jd b/docs/html/guide/topics/manifest/application-element.jd index 2105a50..42cfdd5 100644 --- a/docs/html/guide/topics/manifest/application-element.jd +++ b/docs/html/guide/topics/manifest/application-element.jd @@ -23,6 +23,7 @@ parent.link=manifest-intro.html android:<a href="#persistent">persistent</a>=["true" | "false"] android:<a href="#proc">process</a>="<i>string</i>" android:<a href="#restoreany">restoreAnyVersion</a>=["true" | "false"] + android:<a href="#supportsrtl">supportsRtl</a>=["true" | "false"] android:<a href="#aff">taskAffinity</a>="<i>string</i>" android:<a href="#theme">theme</a>="<i>resource or theme</i>" android:<a href="#uioptions">uiOptions</a>=["none" | "splitActionBarWhenNarrow"] > @@ -271,7 +272,7 @@ applications, reducing resource usage. </p></dd> <dt><a name="restoreany"></a>{@code android:restoreAnyVersion}</dt> -<dd>Indicate that the application is prepared to attempt a restore of any +<dd>Indicates that the application is prepared to attempt a restore of any backed-up data set, even if the backup was stored by a newer version of the application than is currently installed on the device. Setting this attribute to {@code true} will permit the Backup Manager to @@ -281,6 +282,21 @@ incompatible. <em>Use with caution!</em> <p>The default value of this attribute is {@code false}. </p></dd> +<dt><a name="supportsrtl"></a>{@code android:supportsRtl}</dt> +<dd>Declares whether your application is willing to support right-to-left (RTL) layouts. +<p>If set to {@code true} and <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target" +>{@code targetSdkVersion}</a> is set to 17 or higher, various RTL APIs will be +activated and used by the system so your app can display RTL layouts. +If set to {@code false} or if <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target" +>{@code targetSdkVersion}</a> is set to 16 or lower, the RTL APIs will be ignored +or will have no effect and your app will behave the same regardless of the layout +direction associated to the user's Locale choice (your layouts will always be left-to-right). + +<p>The default value of this attribute is {@code false}.</p> + +<p>This attribute was added in API level 17.</p> +</dd> + <dt><a name="aff"></a>{@code android:taskAffinity}</dt> <dd>An affinity name that applies to all activities within the application, except for those that set a different affinity with their own diff --git a/docs/html/guide/topics/manifest/permission-element.jd b/docs/html/guide/topics/manifest/permission-element.jd index c256fb1..a23fb4b 100644 --- a/docs/html/guide/topics/manifest/permission-element.jd +++ b/docs/html/guide/topics/manifest/permission-element.jd @@ -111,7 +111,7 @@ The value can be set to one of the following strings: <td>"{@code signatureOrSystem}"</td> <td>A permission that the system grants only to applications that are in the Android system image <em>or</em> that are signed with the same - certificates as those in the system image. Please avoid using this + certificate as the application that declared the permission. Please avoid using this option, as the {@code signature} protection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "{@code signatureOrSystem}" diff --git a/docs/html/guide/topics/manifest/provider-element.jd b/docs/html/guide/topics/manifest/provider-element.jd index 4558800..6cf6843 100644 --- a/docs/html/guide/topics/manifest/provider-element.jd +++ b/docs/html/guide/topics/manifest/provider-element.jd @@ -5,7 +5,9 @@ parent.link=manifest-intro.html <dl class="xml"> <dt>syntax:</dt> -<dd><pre class="stx"><provider android:<a href="#auth">authorities</a>="<i>list</i>" +<dd> +<pre class="stx"> +<provider android:<a href="#auth">authorities</a>="<i>list</i>" android:<a href="#enabled">enabled</a>=["true" | "false"] android:<a href="#exported">exported</a>=["true" | "false"] android:<a href="#gprmsn">grantUriPermissions</a>=["true" | "false"] @@ -20,10 +22,13 @@ parent.link=manifest-intro.html android:<a href="#sync">syncable</a>=["true" | "false"] android:<a href="#wprmsn">writePermission</a>="<i>string</i>" > . . . -</provider></pre></dd> +</provider></pre> +</dd> <dt>contained in:</dt> -<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd> +<dd> + <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> +</dd> <dt>can contain:</dt> <dd><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> @@ -31,58 +36,67 @@ parent.link=manifest-intro.html <br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission></a></code></dd> <dt>description:</dt> -<dd>Declares a content provider — a subclass of -{@link android.content.ContentProvider} — that supplies structured -access to data managed by the application. All content providers that -are part of the application must be represented by {@code <provider>} -elements in the manifest file. The system cannot see, and therefore will -not run, any that are not declared. (You need to declare only -those content providers that you develop as part of your application, -not those developed by others that your application uses.) - -<p> -The Android system identifies content providers by the authority part - of a {@code content:} URI. For example, suppose that the following URI -is passed to <code>{@link android.content.ContentResolver#query -ContentResolver.query()}</code>: - -<p style="margin-left: 2em">{@code content://com.example.project.healthcareprovider/nurses/rn}</p> - -<p> -The {@code content:} scheme identifies the data as belonging to a content -provider and the authority ({@code com.example.project.healthcareprovider}) -identifies the particular provider. The authority therefore must be unique. -Typically, as in this example, it's the fully qualified name of a -ContentProvider subclass. The path part of a URI may be used by a content -provider to identify particular data subsets, but those paths are not -declared in the manifest. -</p> - -<p> -For information on using and developing content providers, see a separate document, -<a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>. -</p></dd> +<dd> + Declares a content provider component. A content provider is a subclass of + {@link android.content.ContentProvider} that supplies structured access to data managed by the + application. All content providers in your application must be defined in a + {@code <provider>} element in the manifest file; otherwise, the system is unaware of them + and doesn't run them. + <p> + You only declare content providers that are part of your application. Content providers in + other applications that you use in your application should not be declared. + </p> + <p> + The Android system stores references to content providers according to an <b>authority</b> + string, part of the provider's <b>content URI</b>. For example, suppose you want to + access a content provider that stores information about health care professionals. To do + this, you call the method + {@link android.content.ContentResolver#query ContentResolver.query()}, which among other + arguments takes a URI that identifies the provider: + </p> +<pre> +content://com.example.project.healthcareprovider/nurses/rn +</pre> + <p> + The <code>content:</code> <b>scheme</b> identifies the URI as a content URI pointing to + an Android content provider. The authority + <code>com.example.project.healthcareprovider</code> identifies the provider itself; the + Android system looks up the authority in its list of known providers and their authorities. + The substring <code>nurses/rn</code> is a <b>path</b>, which the content provider can use + to identify subsets of the provider data. + </p> + <p> + Notice that when you define your provider in the <code><provider></code> element, you + don't include the scheme or the path in the <code>android:name</code> argument, only the + authority. + </p> + <p> + For information on using and developing content providers, see the API Guide, + <a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>. + </p> +</dd> <dt>attributes:</dt> -<dd><dl class="attr"> -<dt><a name="auth"></a>{@code android:authorities}</dt> -<dd>A list of one or more URI authorities that identify data under the purview -of the content provider. -Multiple authorities are listed by separating their names with a semicolon. -To avoid conflicts, authority names should use a Java-style naming convention -(such as {@code com.example.provider.cartoonprovider}). Typically, it's the name -of the ContentProvider subclass. - -<p> -There is no default. At least one authority must be specified. -</p></dd> - -<dt><a name="enabled"></a>{@code android:enabled}</dt> -<dd>Whether or not the content provider can be instantiated by the system — -"{@code true}" if it can be, and "{@code false}" if not. The default value -is "{@code true}". - -<p> +<dd> + <dl class="attr"> + <dt><a name="auth"></a>{@code android:authorities}</dt> + <dd> + A list of one or more URI authorities that identify data offered by the content provider. + Multiple authorities are listed by separating their names with a semicolon. + To avoid conflicts, authority names should use a Java-style naming convention + (such as {@code com.example.provider.cartoonprovider}). Typically, it's the name + of the {@link android.content.ContentProvider} subclass that implements the provider + <p> + There is no default. At least one authority must be specified. + </p> + </dd> + + <dt><a name="enabled"></a>{@code android:enabled}</dt> + <dd>Whether or not the content provider can be instantiated by the system — + "{@code true}" if it can be, and "{@code false}" if not. The default value + is "{@code true}". + + <p> The <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element has its own <code><a href="{@docRoot}guide/topics/manifest/application-element.html#enabled">enabled</a></code> attribute that applies to all application components, including content providers. The @@ -93,16 +107,37 @@ are by default) for the content provider to be enabled. If either is </p></dd> <dt><a name="exported"></a>{@code android:exported}</dt> -<dd>Whether or not the content provider can be used by components of other -applications — "{@code true}" if it can be, and "{@code false}" if not. -If "{@code false}", the provider is available only to components of the -same application or applications with the same user ID. The default value -is "{@code true}". - -<p> -You can export a content provider but still limit access to it with the -<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn">permission</a></code> attribute. -</p></dd> +<dd> + Whether the content provider is available for other applications to use: + <ul> + <li> + <code>true</code>: The provider is available to other applications. Any application can + use the provider's content URI to access it, subject to the permissions specified for + the provider. + </li> + <li> + <code>false</code>: The provider is not available to other applications. Set + <code>android:exported="false"</code> to limit access to the provider to your + applications. Only applications that have the same user ID (UID) as the provider will + have access to it. + </li> + </ul> + <p> + The default value is <code>"true"</code> for applications that set either +<code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">android:minSdkVersion</a></code> + or +<code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">android:targetSdkVersion</a></code> to + <code>"16"</code> or lower. For applications that + set either of these attributes to <code>"17"</code> or higher, the default is + <code>"false"</code>. + </p> + <p> + You can set <code>android:exported="false"</code> and still limit access to your + provider by setting permissions with the + <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn">permission</a></code> + attribute. + </p> +</dd> <dt><a name="gprmsn"></a>{@code android:grantUriPermissions}</dt> <dd>Whether or not those who ordinarily would not have permission to diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd index a111356..10b5a33 100644 --- a/docs/html/guide/topics/manifest/uses-feature-element.jd +++ b/docs/html/guide/topics/manifest/uses-feature-element.jd @@ -561,7 +561,7 @@ is sensitive to delays or lag in sound input or output.</td> </td> </tr> <tr> - <td rowspan="4">Camera</td> + <td rowspan="5">Camera</td> <td><code>android.hardware.camera</code></td> <td>The application uses the device's camera. If the device supports multiple cameras, the application uses the camera that facing @@ -583,6 +583,12 @@ is sensitive to delays or lag in sound input or output.</td> <td><code>android.hardware.camera.front</code></td> <td>Subfeature. The application uses a front-facing camera on the device.</td> </tr> +<tr> + <td><code>android.hardware.camera.any</code></td> + <td>The application uses at least one camera facing in any direction. Use this +in preference to <code>android.hardware.camera</code> if a back-facing camera is +not required.</td> +</tr> <tr> <td rowspan="3">Location</td> diff --git a/docs/html/guide/topics/providers/content-provider-basics.jd b/docs/html/guide/topics/providers/content-provider-basics.jd index 8c47ad7..527e713 100644 --- a/docs/html/guide/topics/providers/content-provider-basics.jd +++ b/docs/html/guide/topics/providers/content-provider-basics.jd @@ -2,9 +2,7 @@ page.title=Content Provider Basics @jd:body <div id="qv-wrapper"> <div id="qv"> - - - <!-- In this document --> +<!-- In this document --> <h2>In this document</h2> <ol> <li> @@ -238,15 +236,11 @@ page.title=Content Provider Basics </p> <p> For example, to get a list of the words and their locales from the User Dictionary Provider, - you call {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - ContentResolver.query()}. - The {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - query()} method calls the - {@link android.content.ContentProvider#query(Uri, String[], String, String[], String) - ContentProvider.query()} method defined by the User Dictionary Provider. The following lines - of code show a - {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - ContentResolver.query()} call: + you call {@link android.content.ContentResolver#query ContentResolver.query()}. + The {@link android.content.ContentResolver#query query()} method calls the + {@link android.content.ContentProvider#query ContentProvider.query()} method defined by the + User Dictionary Provider. The following lines of code show a + {@link android.content.ContentResolver#query ContentResolver.query()} call: <p> <pre> // Queries the user dictionary and returns results @@ -259,7 +253,7 @@ mCursor = getContentResolver().query( </pre> <p> Table 2 shows how the arguments to - {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) + {@link android.content.ContentResolver#query query(Uri,projection,selection,selectionArgs,sortOrder)} match an SQL SELECT statement: </p> <p class="table-caption"> @@ -344,7 +338,7 @@ content://user_dictionary/words <code>4</code> from user dictionary, you can use this content URI: </p> <pre> -Uri singleUri = ContentUri.withAppendedId(UserDictionary.Words.CONTENT_URI,4); +Uri singleUri = ContentUris.withAppendedId(UserDictionary.Words.CONTENT_URI,4); </pre> <p> You often use id values when you've retrieved a set of rows and then want to update or delete @@ -354,7 +348,7 @@ Uri singleUri = ContentUri.withAppendedId(UserDictionary.Words.CONTENT_URI,4); <strong>Note:</strong> The {@link android.net.Uri} and {@link android.net.Uri.Builder} classes contain convenience methods for constructing well-formed Uri objects from strings. The {@link android.content.ContentUris} contains convenience methods for appending id values to - a URI. The previous snippet uses {@link android.content.ContentUris#withAppendedId(Uri, long) + a URI. The previous snippet uses {@link android.content.ContentUris#withAppendedId withAppendedId()} to append an id to the UserDictionary content URI. </p> @@ -367,10 +361,9 @@ Uri singleUri = ContentUri.withAppendedId(UserDictionary.Words.CONTENT_URI,4); </p> <p class="note"> For the sake of clarity, the code snippets in this section call - {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - ContentResolver.query()} on the "UI thread"". In actual code, however, you should - do queries asynchronously on a separate thread. One way to do this is to use the - {@link android.content.CursorLoader} class, which is described + {@link android.content.ContentResolver#query ContentResolver.query()} on the "UI thread"". In + actual code, however, you should do queries asynchronously on a separate thread. One way to do + this is to use the {@link android.content.CursorLoader} class, which is described in more detail in the <a href="{@docRoot}guide/components/loaders.html"> Loaders</a> guide. Also, the lines of code are snippets only; they don't show a complete application. @@ -391,8 +384,8 @@ Uri singleUri = ContentUri.withAppendedId(UserDictionary.Words.CONTENT_URI,4); To retrieve data from a provider, your application needs "read access permission" for the provider. You can't request this permission at run-time; instead, you have to specify that you need this permission in your manifest, using the - <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> - <uses-permission></a></code> element and the exact permission name defined by the +<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> + element and the exact permission name defined by the provider. When you specify this element in your manifest, you are in effect "requesting" this permission for your application. When users install your application, they implicitly grant this request. @@ -436,10 +429,9 @@ String[] mSelectionArgs = {""}; </pre> <p> The next snippet shows how to use - {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - ContentResolver.query()}, using the User Dictionary Provider as an example. - A provider client query is similar to an SQL query, and it contains a set of columns to return, - a set of selection criteria, and a sort order. + {@link android.content.ContentResolver#query ContentResolver.query()}, using the User Dictionary + Provider as an example. A provider client query is similar to an SQL query, and it contains a + set of columns to return, a set of selection criteria, and a sort order. </p> <p> The set of columns that the query should return is called a <strong>projection</strong> @@ -448,9 +440,9 @@ String[] mSelectionArgs = {""}; <p> The expression that specifies the rows to retrieve is split into a selection clause and selection arguments. The selection clause is a combination of logical and Boolean expressions, - column names, and values (the variable <code>mSelection</code>). If you specify the replaceable - parameter <code>?</code> instead of a value, the query method retrieves the value from the - selection arguments array (the variable <code>mSelectionArgs</code>). + column names, and values (the variable <code>mSelectionClause</code>). If you specify the + replaceable parameter <code>?</code> instead of a value, the query method retrieves the value + from the selection arguments array (the variable <code>mSelectionArgs</code>). </p> <p> In the next snippet, if the user doesn't enter a word, the selection clause is set to @@ -517,7 +509,7 @@ if (null == mCursor) { This query is analogous to the SQL statement: </p> <pre> -SELECT _ID, word, frequency, locale FROM words WHERE word = <userinput> ORDER BY word ASC; +SELECT _ID, word, locale FROM words WHERE word = <userinput> ORDER BY word ASC; </pre> <p> In this SQL statement, the actual column names are used instead of contract class constants. @@ -575,16 +567,15 @@ selectionArgs[0] = mUserInput; <!-- Displaying the results --> <h3 id="DisplayResults">Displaying query results</h3> <p> - The {@link android.content.ContentResolver#query(Uri, String[], String, String[], String) - ContentResolver.query()} client method always returns a {@link android.database.Cursor} - containing the columns specified by the query's projection for the rows that match the query's - selection criteria. A {@link android.database.Cursor} object provides random read access to the - rows and columns it contains. Using {@link android.database.Cursor} methods, - you can iterate over the rows in the results, determine the data type of each column, get the - data out of a column, and examine other properties of the results. Some - {@link android.database.Cursor} implementations automatically update the object when the - provider's data changes, or trigger methods in an observer object when the - {@link android.database.Cursor} changes, or both. + The {@link android.content.ContentResolver#query ContentResolver.query()} client method always + returns a {@link android.database.Cursor} containing the columns specified by the query's + projection for the rows that match the query's selection criteria. A + {@link android.database.Cursor} object provides random read access to the rows and columns it + contains. Using {@link android.database.Cursor} methods, you can iterate over the rows in the + results, determine the data type of each column, get the data out of a column, and examine other + properties of the results. Some {@link android.database.Cursor} implementations automatically + update the object when the provider's data changes, or trigger methods in an observer object + when the {@link android.database.Cursor} changes, or both. </p> <p class="note"> <strong>Note:</strong> A provider may restrict access to columns based on the nature of the @@ -594,7 +585,7 @@ selectionArgs[0] = mUserInput; <p> If no rows match the selection criteria, the provider returns a {@link android.database.Cursor} object for which - {@link android.database.Cursor#getCount() Cursor.getCount()} is 0 (an empty cursor). + {@link android.database.Cursor#getCount Cursor.getCount()} is 0 (an empty cursor). </p> <p> If an internal error occurs, the results of the query depend on the particular provider. It may @@ -685,8 +676,8 @@ if (mCursor != null) { <p> {@link android.database.Cursor} implementations contain several "get" methods for retrieving different types of data from the object. For example, the previous snippet - uses {@link android.database.Cursor#getString(int) getString()}. They also have a - {@link android.database.Cursor#getType(int) getType()} method that returns a value indicating + uses {@link android.database.Cursor#getString getString()}. They also have a + {@link android.database.Cursor#getType getType()} method that returns a value indicating the data type of the column. </p> @@ -713,17 +704,16 @@ if (mCursor != null) { </p> <p> To get the permissions needed to access a provider, an application requests them with a - <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> - <uses-permission></a></code> element in its manifest file. - When the Android Package Manager installs the application, a user must approve all of the - permissions the application requests. If the user approves all of them, Package Manager - continues the installation; if the user doesn't approve them, Package Manager +<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> + element in its manifest file. When the Android Package Manager installs the application, a user + must approve all of the permissions the application requests. If the user approves all of them, + Package Manager continues the installation; if the user doesn't approve them, Package Manager aborts the installation. </p> <p> The following - <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> - <uses-permission></a></code> element requests read access to the User Dictionary Provider: +<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> + element requests read access to the User Dictionary Provider: </p> <pre> <uses-permission android:name="android.permission.READ_USER_DICTIONARY"> @@ -746,7 +736,7 @@ if (mCursor != null) { <h3 id="Inserting">Inserting data</h3> <p> To insert data into a provider, you call the - {@link android.content.ContentResolver#insert(Uri,ContentValues) ContentResolver.insert()} + {@link android.content.ContentResolver#insert ContentResolver.insert()} method. This method inserts a new row into the provider and returns a content URI for that row. This snippet shows how to insert a new word into the User Dictionary Provider: </p> @@ -777,8 +767,7 @@ mNewUri = getContentResolver().insert( The data for the new row goes into a single {@link android.content.ContentValues} object, which is similar in form to a one-row cursor. The columns in this object don't need to have the same data type, and if you don't want to specify a value at all, you can set a column - to <code>null</code> using {@link android.content.ContentValues#putNull(String) - ContentValues.putNull()}. + to <code>null</code> using {@link android.content.ContentValues#putNull ContentValues.putNull()}. </p> <p> The snippet doesn't add the <code>_ID</code> column, because this column is maintained @@ -799,17 +788,16 @@ content://user_dictionary/words/<id_value> </p> <p> To get the value of <code>_ID</code> from the returned {@link android.net.Uri}, call - {@link android.content.ContentUris#parseId(Uri) ContentUris.parseId()}. + {@link android.content.ContentUris#parseId ContentUris.parseId()}. </p> <h3 id="Updating">Updating data</h3> <p> To update a row, you use a {@link android.content.ContentValues} object with the updated values just as you do with an insertion, and selection criteria just as you do with a query. The client method you use is - {@link android.content.ContentResolver#update(Uri, ContentValues, String, String[]) - ContentResolver.update()}. You only need to add values to the - {@link android.content.ContentValues} object for columns you're updating. If you want to clear - the contents of a column, set the value to <code>null</code>. + {@link android.content.ContentResolver#update ContentResolver.update()}. You only need to add + values to the {@link android.content.ContentValues} object for columns you're updating. If you + want to clear the contents of a column, set the value to <code>null</code>. </p> <p> The following snippet changes all the rows whose locale has the language "en" to a @@ -842,9 +830,8 @@ mRowsUpdated = getContentResolver().update( </pre> <p> You should also sanitize user input when you call - {@link android.content.ContentResolver#update(Uri, ContentValues, String, String[]) - ContentResolver.update()}. To learn more about this, read the section - <a href="#Injection">Protecting against malicious input</a>. + {@link android.content.ContentResolver#update ContentResolver.update()}. To learn more about + this, read the section <a href="#Injection">Protecting against malicious input</a>. </p> <h3 id="Deleting">Deleting data</h3> <p> @@ -873,9 +860,8 @@ mRowsDeleted = getContentResolver().delete( </pre> <p> You should also sanitize user input when you call - {@link android.content.ContentResolver#delete(Uri, String, String[]) - ContentResolver.delete()}. To learn more about this, read the section - <a href="#Injection">Protecting against malicious input</a>. + {@link android.content.ContentResolver#delete ContentResolver.delete()}. To learn more about + this, read the section <a href="#Injection">Protecting against malicious input</a>. </p> <!-- Provider Data Types --> <h2 id="DataTypes">Provider Data Types</h2> @@ -907,7 +893,7 @@ mRowsDeleted = getContentResolver().delete( The data types for the User Dictionary Provider are listed in the reference documentation for its contract class {@link android.provider.UserDictionary.Words} (contract classes are described in the section <a href="#ContractClasses">Contract Classes</a>). - You can also determine the data type by calling {@link android.database.Cursor#getType(int) + You can also determine the data type by calling {@link android.database.Cursor#getType Cursor.getType()}. </p> <p> @@ -918,7 +904,7 @@ mRowsDeleted = getContentResolver().delete( data structures or files. For example, the {@link android.provider.ContactsContract.Data} table in the Contacts Provider uses MIME types to label the type of contact data stored in each row. To get the MIME type corresponding to a content URI, call - {@link android.content.ContentResolver#getType(Uri) ContentResolver.getType()}. + {@link android.content.ContentResolver#getType ContentResolver.getType()}. </p> <p> The section <a href="#MIMETypeReference">MIME Type Reference</a> describes the @@ -935,8 +921,7 @@ mRowsDeleted = getContentResolver().delete( <li> <a href="#Batch">Batch access</a>: You can create a batch of access calls with methods in the {@link android.content.ContentProviderOperation} class, and then apply them with - {@link android.content.ContentResolver#applyBatch(String, ArrayList) - ContentResolver.applyBatch()}. + {@link android.content.ContentResolver#applyBatch ContentResolver.applyBatch()}. </li> <li> Asynchronous queries: You should do queries in a separate thread. One way to do this is to @@ -963,11 +948,10 @@ mRowsDeleted = getContentResolver().delete( To access a provider in "batch mode", you create an array of {@link android.content.ContentProviderOperation} objects and then dispatch them to a content provider with - {@link android.content.ContentResolver#applyBatch(String, ArrayList) - ContentResolver.applyBatch()}. You pass the content provider's <em>authority</em> to this - method, rather than a particular content URI, which allows each - {@link android.content.ContentProviderOperation} object in the array to work against a - different table. A call to {@link android.content.ContentResolver#applyBatch(String, ArrayList) + {@link android.content.ContentResolver#applyBatch ContentResolver.applyBatch()}. You pass the + content provider's <em>authority</em> to this method, rather than a particular content URI. + This allows each {@link android.content.ContentProviderOperation} object in the array to work + against a different table. A call to {@link android.content.ContentResolver#applyBatch ContentResolver.applyBatch()} returns an array of results. </p> <p> @@ -1028,14 +1012,13 @@ mRowsDeleted = getContentResolver().delete( </p> <p> A provider defines URI permissions for content URIs in its manifest, using the - <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"> - android:grantUriPermission</a></code> - attribute of the <a href="{@docRoot}guide/topics/manifest/provider-element.html"> - {@code <provider>}</a> +<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn">android:grantUriPermission</a></code> + attribute of the +<code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code> element, as well as the - <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html">{@code - <grant-uri-permission>}</a> child element of the - <a href="{@docRoot}guide/topics/manifest/provider-element.html">{@code <provider>}</a> +<code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> + child element of the +<code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code> element. The URI permissions mechanism is explained in more detail in the <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a> guide, in the section "URI Permissions". @@ -1053,7 +1036,7 @@ mRowsDeleted = getContentResolver().delete( Your application sends an intent containing the action {@link android.content.Intent#ACTION_PICK} and the "contacts" MIME type {@link android.provider.ContactsContract.RawContacts#CONTENT_ITEM_TYPE}, using the - method {@link android.app.Activity#startActivityForResult(Intent, int) + method {@link android.app.Activity#startActivityForResult startActivityForResult()}. </li> <li> @@ -1063,7 +1046,7 @@ mRowsDeleted = getContentResolver().delete( <li> In the selection activity, the user selects a contact to update. When this happens, the selection activity calls - {@link android.app.Activity#setResult(int, Intent) setResult(resultcode, intent)} + {@link android.app.Activity#setResult setResult(resultcode, intent)} to set up a intent to give back to your application. The intent contains the content URI of the contact the user selected, and the "extras" flags {@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION}. These flags grant URI @@ -1073,7 +1056,7 @@ mRowsDeleted = getContentResolver().delete( </li> <li> Your activity returns to the foreground, and the system calls your activity's - {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult()} + {@link android.app.Activity#onActivityResult onActivityResult()} method. This method receives the result intent created by the selection activity in the People app. </li> diff --git a/docs/html/guide/topics/resources/providing-resources.jd b/docs/html/guide/topics/resources/providing-resources.jd index cf2c03e..b311b7f 100644 --- a/docs/html/guide/topics/resources/providing-resources.jd +++ b/docs/html/guide/topics/resources/providing-resources.jd @@ -329,6 +329,39 @@ your application for other languages.</p> indicates the current locale.</p> </td> </tr> + <tr id="LayoutDirectionQualifier"> + <td>Layout Direction</td> + <td><code>ldrtl</code><br/> + <code>ldltr</code><br/> + </td> + <td><p>The layout direction of your application. {@code ldrtl} means "layout-direction-right-to-left". + {@code ldltr} means "layout-direction-left-to-right" and is the default implicit value. + </p> + <p>This can apply to any resource such as layouts, drawables, or values. + </p> + <p>For example, if you want to provide some specific layout for the Arabic language and some + generic layout for any other "right-to-left" language (like Persian or Hebrew) then you would have: + </p> +<pre class="classic no-pretty-print"> +res/ + layout/ <span style="color:black"> + main.xml </span>(Default layout) + layout-ar/ <span style="color:black"> + main.xml </span>(Specific layout for Arabic) + layout-ldrtl/ <span style="color:black"> + main.xml </span>(Any "right-to-left" language, except + for Arabic, because the "ar" language qualifier + has a higher precedence.) +</pre> + <p class="note"><strong>Note:</strong> To enable right-to-left layout features + for your app, you must set <a + href="{@docRoot}guide/topics/manifest/application-element.html#supportsrtl">{@code + supportsRtl}</a> to {@code "true"} and set <a + href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target" + >{@code targetSdkVersion}</a> to 17 or higher.</p> + <p><em>Added in API level 17.</em></p> + </td> + </tr> <tr id="SmallestScreenWidthQualifier"> <td>smallestWidth</td> <td><code>sw<N>dp</code><br/><br/> diff --git a/docs/html/guide/topics/resources/string-resource.jd b/docs/html/guide/topics/resources/string-resource.jd index 5f5484e..da410a4 100644 --- a/docs/html/guide/topics/resources/string-resource.jd +++ b/docs/html/guide/topics/resources/string-resource.jd @@ -13,8 +13,7 @@ your application with strings:</p> <dt><a href="#StringArray">String Array</a></dt> <dd>XML resource that provides an array of strings.</dd> <dt><a href="#Plurals">Quantity Strings (Plurals)</a></dt> - <dd>XML resource that carries different strings for different quantities - of the same word or phrase.</dd> + <dd>XML resource that carries different strings for pluralization.</dd> </dl> <p>All strings are capable of applying some styling markup and formatting arguments. For @@ -231,10 +230,19 @@ so Android provides you with methods such as {@link android.content.res.Resources#getQuantityString(int,int) getQuantityString()} to select the appropriate resource for you. -<p>Note that the selection is made based on grammatical necessity. A string for <code>zero</code> -in English will be ignored even if the quantity is 0, because 0 isn't grammatically different -from 2, or any other number except 1 ("zero books", "one book", "two books", and so on). -Don't be misled either by the fact that, say, <code>two</code> sounds like it could only apply to +<p>Although historically called "quantity strings" (and still called that in API), quantity +strings should <i>only</i> be used for plurals. It would be a mistake to use quantity strings to +implement something like Gmail's "Inbox" versus "Inbox (12)" when there are unread messages, for +example. It might seem convenient to use quantity strings instead of an {@code if} statement, +but it's important to note that some languages (such as Chinese) don't make these grammatical +distinctions at all, so you'll always get the <code>other</code> string. + +<p>The selection of which string to use is made solely based on grammatical <i>necessity</i>. +In English, a string for <code>zero</code> will be ignored even if the quantity is 0, because 0 +isn't grammatically different from 2, or any other number except 1 ("zero books", "one book", +"two books", and so on). + +<p>Don't be misled either by the fact that, say, <code>two</code> sounds like it could only apply to the quantity 2: a language may require that 2, 12, 102 (and so on) are all treated like one another but differently to other quantities. Rely on your translator to know what distinctions their language actually insists upon. @@ -313,7 +321,7 @@ values, with non-exhaustive examples in parentheses: <td>{@code one}</td><td>When the language requires special treatment of numbers like one (as with the number 1 in English and most other languages; in Russian, any number ending in 1 but not ending in 11 is in this class).</td> </tr> <tr> - <td>{@code two}</td><td>When the language requires special treatment of numbers like two (as in Welsh).</td> + <td>{@code two}</td><td>When the language requires special treatment of numbers like two (as with 2 in Welsh, or 102 in Slovenian).</td> </tr> <tr> <td>{@code few}</td><td>When the language requires special treatment of "small" numbers (as with 2, 3, and 4 in Czech; or numbers ending 2, 3, or 4 but not 12, 13, or 14 in Polish).</td> @@ -322,7 +330,7 @@ values, with non-exhaustive examples in parentheses: <td>{@code many}</td><td>When the language requires special treatment of "large" numbers (as with numbers ending 11-99 in Maltese).</td> </tr> <tr> - <td>{@code other}</td><td>When the language does not require special treatment of the given quantity.</td> + <td>{@code other}</td><td>When the language does not require special treatment of the given quantity (as with all numbers in Chinese, or 42 in English).</td> </tr> </table> </dd> |
