docs: remove trailing white space from jd files
Change-Id: Id7fb958460bf2f28d88c6120df0395690f32783a
diff --git a/docs/html/training/accessibility/accessible-app.jd b/docs/html/training/accessibility/accessible-app.jd
index dd26feb..54c185c 100644
--- a/docs/html/training/accessibility/accessible-app.jd
+++ b/docs/html/training/accessibility/accessible-app.jd
@@ -55,7 +55,7 @@
If you have a label that's likely not to change during the lifecycle of the
application (such as "Pause" or "Purchase"), you can add it via the XML layout,
by setting a UI element's <a
-
+
href="{@docRoot}reference/android/view/View.html#attr_android:contentDescription"
>{@code android:contentDescription}</a> attribute, like in this
example:</p>
@@ -163,7 +163,7 @@
android.view.accessibility.AccessibilityEvent} reference documentation.
<p>As an example, if you want to extend an image view such that you can write
-captions by typing on the keyboard when it has focus, it makes sense to fire an
+captions by typing on the keyboard when it has focus, it makes sense to fire an
{@link android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED}
event, even though that's not normally built into image views. The code to
generate that event would look like this:</p>
diff --git a/docs/html/training/accessibility/service.jd b/docs/html/training/accessibility/service.jd
index 5b99c46..9935c97 100755
--- a/docs/html/training/accessibility/service.jd
+++ b/docs/html/training/accessibility/service.jd
@@ -67,7 +67,7 @@
<p>Like any other service, you also declare it in the manifest file.
Remember to specify that it handles the {@code android.accessibilityservice} intent,
-so that the service is called when applications fire an
+so that the service is called when applications fire an
{@link android.view.accessibility.AccessibilityEvent}.</p>
<pre>
diff --git a/docs/html/training/animation/screen-slide.jd b/docs/html/training/animation/screen-slide.jd
index a68d475..d953c07 100644
--- a/docs/html/training/animation/screen-slide.jd
+++ b/docs/html/training/animation/screen-slide.jd
@@ -218,7 +218,7 @@
position of the page on the screen, which is obtained from the <code>position</code> parameter
of the {@link android.support.v4.view.ViewPager.PageTransformer#transformPage transformPage()} method.</p>
-<p>The <code>position</code> parameter indicates where a given page is located relative to the center of the screen.
+<p>The <code>position</code> parameter indicates where a given page is located relative to the center of the screen.
It is a dynamic property that changes as the user scrolls through the pages. When a page fills the screen, its position value is <code>0</code>.
When a page is drawn just off the right side of the screen, its position value is <code>1</code>. If the user scrolls halfway between pages one and two, page one has a position of -0.5 and page two has a position of 0.5. Based on the position of the pages on the screen, you can create custom slide animations by setting page properties with methods such as {@link android.view.View#setAlpha setAlpha()}, {@link android.view.View#setTranslationX setTranslationX()}, or
{@link android.view.View#setScaleY setScaleY()}.</p>
diff --git a/docs/html/training/animation/zoom.jd b/docs/html/training/animation/zoom.jd
index 6a38e7d..60de70e 100644
--- a/docs/html/training/animation/zoom.jd
+++ b/docs/html/training/animation/zoom.jd
@@ -297,13 +297,13 @@
set.play(ObjectAnimator
.ofFloat(expandedImageView, View.X, startBounds.left))
.with(ObjectAnimator
- .ofFloat(expandedImageView,
+ .ofFloat(expandedImageView,
View.Y,startBounds.top))
.with(ObjectAnimator
- .ofFloat(expandedImageView,
+ .ofFloat(expandedImageView,
View.SCALE_X, startScaleFinal))
.with(ObjectAnimator
- .ofFloat(expandedImageView,
+ .ofFloat(expandedImageView,
View.SCALE_Y, startScaleFinal));
set.setDuration(mShortAnimationDuration);
set.setInterpolator(new DecelerateInterpolator());
diff --git a/docs/html/training/app-indexing/deep-linking.jd b/docs/html/training/app-indexing/deep-linking.jd
index 2c4a131..a68e5a3 100644
--- a/docs/html/training/app-indexing/deep-linking.jd
+++ b/docs/html/training/app-indexing/deep-linking.jd
@@ -69,7 +69,7 @@
<!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="example"
android:host="gizmos" />
-
+
</intent-filter>
</activity>
</pre>
diff --git a/docs/html/training/articles/perf-anr.jd b/docs/html/training/articles/perf-anr.jd
index bbebec5..2eda4fa 100644
--- a/docs/html/training/articles/perf-anr.jd
+++ b/docs/html/training/articles/perf-anr.jd
@@ -64,10 +64,10 @@
and Window Manager system services. Android will display the ANR dialog
for a particular application when it detects one of the following
conditions:</p>
-<ul>
- <li>No response to an input event (such as key press or screen touch events)
+<ul>
+ <li>No response to an input event (such as key press or screen touch events)
within 5 seconds.</li>
- <li>A {@link android.content.BroadcastReceiver BroadcastReceiver}
+ <li>A {@link android.content.BroadcastReceiver BroadcastReceiver}
hasn't finished executing within 10 seconds.</li>
</ul>
@@ -100,7 +100,7 @@
{@link android.os.AsyncTask#onProgressUpdate onProgressUpdate()} callback method. From your
implementation of {@link android.os.AsyncTask#onProgressUpdate onProgressUpdate()} (which
runs on the UI thread), you can notify the user. For example:</p>
-
+
<pre>
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
// Do the long-running work in here
@@ -127,14 +127,14 @@
}
}
</pre>
-
+
<p>To execute this worker thread, simply create an instance and
call {@link android.os.AsyncTask#execute execute()}:</p>
-
+
<pre>
new DownloadFilesTask().execute(url1, url2, url3);
</pre>
-
+
<p>Although it's more complicated than {@link android.os.AsyncTask}, you might want to instead
create your own {@link java.lang.Thread} or {@link android.os.HandlerThread} class. If you do,
@@ -143,7 +143,7 @@
android.os.Process#THREAD_PRIORITY_BACKGROUND}. If you don't set the thread to a lower priority
this way, then the thread could still slow down your app because it operates at the same priority
as the UI thread by default.</p>
-
+
<p>If you implement {@link java.lang.Thread} or {@link android.os.HandlerThread},
be sure that your UI thread does not block while waiting for the worker thread to
complete—do not call {@link java.lang.Thread#wait Thread.wait()} or
@@ -183,16 +183,16 @@
<li>If your application is doing work in the background in response to
user input, show that progress is being made (such as with a {@link
android.widget.ProgressBar} in your UI).</li>
-
+
<li>For games specifically, do calculations for moves in a worker
thread.</li>
-
+
<li>If your application has a time-consuming initial setup phase, consider
showing a splash screen or rendering the main view as quickly as possible, indicate that
loading is in progress and fill the information asynchronously. In either case, you should
indicate somehow that progress is being made, lest the user perceive that
the application is frozen.</li>
-
+
<li>Use performance tools such as <a href="{@docRoot}tools/help/systrace.html">Systrace</a>
and <a href="{@docRoot}tools/help/traceview.html">Traceview</a> to determine bottlenecks
in your app's responsiveness.</li>
diff --git a/docs/html/training/articles/perf-jni.jd b/docs/html/training/articles/perf-jni.jd
index 5a9fa1e..8d2fd9b 100644
--- a/docs/html/training/articles/perf-jni.jd
+++ b/docs/html/training/articles/perf-jni.jd
@@ -564,9 +564,9 @@
that looked through the weak globals table, the arguments, the locals
table, and the globals table in that order. The first time it found your
direct pointer, it would report that your reference was of the type it
- happened to be examining. This meant, for example, that if
+ happened to be examining. This meant, for example, that if
you called <code>GetObjectRefType</code> on a global jclass that happened
- to be the same as the jclass passed as an implicit argument to your static
+ to be the same as the jclass passed as an implicit argument to your static
native method, you'd get <code>JNILocalRefType</code> rather than
<code>JNIGlobalRefType</code>.
</ul>
diff --git a/docs/html/training/articles/smp.jd b/docs/html/training/articles/smp.jd
index 0b45987..a95931b 100644
--- a/docs/html/training/articles/smp.jd
+++ b/docs/html/training/articles/smp.jd
@@ -75,7 +75,7 @@
multiprocessor architectures. This document introduces issues that
can arise when writing code for symmetric multiprocessor systems in C, C++, and the Java
programming language (hereafter referred to simply as “Java” for the sake of
-brevity). It's intended as a primer for Android app developers, not as a complete
+brevity). It's intended as a primer for Android app developers, not as a complete
discussion on the subject. The focus is on the ARM CPU architecture.</p>
<p>If you’re in a hurry, you can skip the <a href="#theory">Theory</a> section
diff --git a/docs/html/training/articles/user-data-overview.jd b/docs/html/training/articles/user-data-overview.jd
index 8715d36..dc0df20 100644
--- a/docs/html/training/articles/user-data-overview.jd
+++ b/docs/html/training/articles/user-data-overview.jd
@@ -266,4 +266,4 @@
href="http://stackoverflow.com/questions/24374701/alternative-to-read-phone-state-permission-for-getting-notified-of-call">source</a>)</em></p>
<p>[2] <em>Using Personal Examples to Improve Risk Communication for Security and Privacy Decisions</em>, by M. Harbach, M. Hettig, S. Weber, and M. Smith. In Proceedings of ACM CHI 2014.</p>
<p>[3] <em>Modeling Users’ Mobile App Privacy Preferences: Restoring Usability in a Sea of Permission Settings</em>, by J. Lin B. Liu, N. Sadeh and J. Hong. In Proceedings of SOUPS 2014.</p>
-<p>[4] <em>Teens and Mobile Apps Privacy. (<a href="http://www.pewinternet.org/files/old-media/Files/Reports/2013/PIP_Teens%20and%20Mobile%20Apps%20Privacy.pdf">source</a>)</em></p>
+<p>[4] <em>Teens and Mobile Apps Privacy. (<a href="http://www.pewinternet.org/files/old-media/Files/Reports/2013/PIP_Teens%20and%20Mobile%20Apps%20Privacy.pdf">source</a>)</em></p>
diff --git a/docs/html/training/articles/user-data-permissions.jd b/docs/html/training/articles/user-data-permissions.jd
index edc7558..ace5f7f 100644
--- a/docs/html/training/articles/user-data-permissions.jd
+++ b/docs/html/training/articles/user-data-permissions.jd
@@ -56,7 +56,7 @@
see <a href="{@docRoot}training/permissions/index.html">Working with System Permissions</a>.
For best practices for working with unique identifiers, please see <a href=
"{@docRoot}training/articles/user-data-ids.html">Best Practices for
- Unique Identifiers</a>.
+ Unique Identifiers</a>.
</p>
<h2 id="tenets_of_working_with_android_permissions">Tenets of Working
diff --git a/docs/html/training/basics/activity-lifecycle/index.jd b/docs/html/training/basics/activity-lifecycle/index.jd
index afeab86..95ed21e 100644
--- a/docs/html/training/basics/activity-lifecycle/index.jd
+++ b/docs/html/training/basics/activity-lifecycle/index.jd
@@ -41,7 +41,7 @@
lifecycle. For instance, when your
activity starts for the first time, it comes to the foreground of the system and receives user
focus. During this process, the Android system calls a series of lifecycle methods on the
-activity in which you set up the user interface and other components. If the user performs an
+activity in which you set up the user interface and other components. If the user performs an
action that starts another activity or switches to another app, the system calls another set of
lifecycle methods on your activity as it moves into the background (where the activity is no
longer visible, but the instance and its state remains intact).</p>
@@ -57,7 +57,7 @@
user expects and does not consume system resources when your activity doesn't need them.</p>
<h2>Lessons</h2>
-
+
<dl>
<dt><b><a href="starting.html">Starting an Activity</a></b></dt>
<dd>Learn the basics about the activity lifecycle, how the user can launch your app, and how
@@ -70,5 +70,5 @@
<dt><b><a href="recreating.html">Recreating an Activity</a></b></dt>
<dd>Learn what happens when your activity is destroyed and how you can rebuild the activity
state when necessary.</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/basics/activity-lifecycle/pausing.jd b/docs/html/training/basics/activity-lifecycle/pausing.jd
index 223e41a..7ca97aa 100644
--- a/docs/html/training/basics/activity-lifecycle/pausing.jd
+++ b/docs/html/training/basics/activity-lifecycle/pausing.jd
@@ -8,13 +8,13 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#Pause">Pause Your Activity</a></li>
<li><a href="#Resume">Resume Your Activity</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/components/activities.html">Activities</a>
@@ -32,7 +32,7 @@
</div>
</div>
-<p>During normal app use, the foreground activity is sometimes obstructed by other
+<p>During normal app use, the foreground activity is sometimes obstructed by other
visual components that cause the activity to <em>pause</em>. For example, when a semi-transparent
activity opens (such as one in the style of a dialog), the previous activity pauses. As long as the
activity is still partially visible but currently not the activity in focus, it remains paused.</p>
@@ -60,7 +60,7 @@
<h2 id="Pause">Pause Your Activity</h2>
-
+
<p>When the system calls {@link android.app.Activity#onPause()} for your activity, it
technically means your activity is still partially visible, but most often is an indication that
the user is leaving the activity and it will soon enter the Stopped state. You should usually use
diff --git a/docs/html/training/basics/activity-lifecycle/recreating.jd b/docs/html/training/basics/activity-lifecycle/recreating.jd
index a52d5fd..60a33774 100644
--- a/docs/html/training/basics/activity-lifecycle/recreating.jd
+++ b/docs/html/training/basics/activity-lifecycle/recreating.jd
@@ -8,13 +8,13 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#SaveState">Save Your Activity State</a></li>
<li><a href="#RestoreState">Restore Your Activity State</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}training/basics/supporting-devices/screens.html">Supporting
@@ -106,7 +106,7 @@
// Save the user's current game state
savedInstanceState.putInt(STATE_SCORE, mCurrentScore);
savedInstanceState.putInt(STATE_LEVEL, mCurrentLevel);
-
+
// Always call the superclass so it can save the view hierarchy state
super.onSaveInstanceState(savedInstanceState);
}
@@ -139,7 +139,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // Always call the superclass first
-
+
// Check whether we're recreating a previously destroyed instance
if (savedInstanceState != null) {
// Restore value of members from saved state
@@ -158,12 +158,12 @@
after the {@link android.app.Activity#onStart()} method. The system calls {@link
android.app.Activity#onRestoreInstanceState onRestoreInstanceState()} only if there is a saved
state to restore, so you do not need to check whether the {@link android.os.Bundle} is null:</p>
-
+
<pre>
public void onRestoreInstanceState(Bundle savedInstanceState) {
// Always call the superclass so it can restore the view hierarchy
super.onRestoreInstanceState(savedInstanceState);
-
+
// Restore state members from saved instance
mCurrentScore = savedInstanceState.getInt(STATE_SCORE);
mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL);
diff --git a/docs/html/training/basics/activity-lifecycle/starting.jd b/docs/html/training/basics/activity-lifecycle/starting.jd
index 5b238b8..06f3a6c 100644
--- a/docs/html/training/basics/activity-lifecycle/starting.jd
+++ b/docs/html/training/basics/activity-lifecycle/starting.jd
@@ -9,7 +9,7 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#lifecycle-states">Understand the Lifecycle Callbacks</a></li>
@@ -17,7 +17,7 @@
<li><a href="#Create">Create a New Instance</a></li>
<li><a href="#Destroy">Destroy the Activity</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/components/activities.html">Activities</a></li>
@@ -84,7 +84,7 @@
</ul>
<!--
-<p class="table-caption"><strong>Table 1.</strong> Activity lifecycle state pairs and callback
+<p class="table-caption"><strong>Table 1.</strong> Activity lifecycle state pairs and callback
methods.</p>
<table>
<tr>
@@ -139,7 +139,7 @@
-<h2 id="launching-activity">Specify Your App's Launcher Activity</h2>
+<h2 id="launching-activity">Specify Your App's Launcher Activity</h2>
<p>When the user selects your app icon from the Home screen, the system calls the {@link
android.app.Activity#onCreate onCreate()} method for the {@link android.app.Activity} in your app
@@ -154,7 +154,7 @@
href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code
<intent-filter>}</a> that includes the {@link
android.content.Intent#ACTION_MAIN MAIN} action and
-{@link android.content.Intent#CATEGORY_LAUNCHER LAUNCHER} category. For example:</p>
+{@link android.content.Intent#CATEGORY_LAUNCHER LAUNCHER} category. For example:</p>
<pre>
<activity android:name=".MainActivity" android:label="@string/app_name">
@@ -203,10 +203,10 @@
// Set the user interface layout for this Activity
// The layout file is defined in the project res/layout/main_activity.xml file
setContentView(R.layout.main_activity);
-
+
// Initialize member TextView so we can manipulate it later
mTextView = (TextView) findViewById(R.id.text_message);
-
+
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// For the main activity, make sure the app icon in the action bar
@@ -271,7 +271,7 @@
@Override
public void onDestroy() {
super.onDestroy(); // Always call the superclass
-
+
// Stop method tracing that the activity started during onCreate()
android.os.Debug.stopMethodTracing();
}
diff --git a/docs/html/training/basics/activity-lifecycle/stopping.jd b/docs/html/training/basics/activity-lifecycle/stopping.jd
index 51c95ea..3246374 100644
--- a/docs/html/training/basics/activity-lifecycle/stopping.jd
+++ b/docs/html/training/basics/activity-lifecycle/stopping.jd
@@ -8,13 +8,13 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#Stop">Stop Your Activity</a></li>
<li><a href="#Start">Start/Restart Your Activity</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/components/activities.html">Activities</a>
@@ -154,13 +154,13 @@
@Override
protected void onStart() {
super.onStart(); // Always call the superclass method first
-
+
// The activity is either being restarted or started for the first time
// so this is where we should make sure that GPS is enabled
- LocationManager locationManager =
+ LocationManager locationManager =
(LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
-
+
if (!gpsEnabled) {
// Create a dialog here that requests the user to enable GPS, and use an intent
// with the android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS action
@@ -171,8 +171,8 @@
@Override
protected void onRestart() {
super.onRestart(); // Always call the superclass method first
-
- // Activity being restarted from stopped state
+
+ // Activity being restarted from stopped state
}
</pre>
diff --git a/docs/html/training/basics/data-storage/databases.jd b/docs/html/training/basics/data-storage/databases.jd
index 4a91d0d..f42bf65 100644
--- a/docs/html/training/basics/data-storage/databases.jd
+++ b/docs/html/training/basics/data-storage/databases.jd
@@ -119,11 +119,11 @@
accessible to other applications.</p>
<p>A useful set of APIs is available in the {@link
-android.database.sqlite.SQLiteOpenHelper} class.
+android.database.sqlite.SQLiteOpenHelper} class.
When you use this class to obtain references to your database, the system
-performs the potentially
+performs the potentially
long-running operations of creating and updating the database only when
-needed and <em>not during app startup</em>. All you need to do is call
+needed and <em>not during app startup</em>. All you need to do is call
{@link android.database.sqlite.SQLiteOpenHelper#getWritableDatabase} or
{@link android.database.sqlite.SQLiteOpenHelper#getReadableDatabase}.</p>
diff --git a/docs/html/training/basics/fragments/communicating.jd b/docs/html/training/basics/fragments/communicating.jd
index 8c1ae21a..2e12072 100644
--- a/docs/html/training/basics/fragments/communicating.jd
+++ b/docs/html/training/basics/fragments/communicating.jd
@@ -7,14 +7,14 @@
@jd:body
<div id="tb-wrapper">
- <div id="tb">
+ <div id="tb">
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#DefineInterface">Define an Interface</a></li>
<li><a href="#Implement">Implement the Interface</a></li>
<li><a href="#Deliver">Deliver a Message to a Fragment</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/components/fragments.html">Fragments</a></li>
@@ -31,21 +31,21 @@
</div>
</div>
-<p>In order to reuse the Fragment UI components, you should build each as a completely
-self-contained, modular component that defines its own layout and behavior. Once you
-have defined these reusable Fragments, you can associate them with an Activity and
+<p>In order to reuse the Fragment UI components, you should build each as a completely
+self-contained, modular component that defines its own layout and behavior. Once you
+have defined these reusable Fragments, you can associate them with an Activity and
connect them with the application logic to realize the overall composite UI.</p>
-<p>Often you will want one Fragment to communicate with another, for example to change
-the content based on a user event. All Fragment-to-Fragment communication is done
+<p>Often you will want one Fragment to communicate with another, for example to change
+the content based on a user event. All Fragment-to-Fragment communication is done
through the associated Activity. Two Fragments should never communicate directly.</p>
<h2 id="DefineInterface">Define an Interface</h2>
-<p>To allow a Fragment to communicate up to its Activity, you can define an interface
-in the Fragment class and implement it within the Activity. The Fragment captures
-the interface implementation during its onAttach() lifecycle method and can then call
+<p>To allow a Fragment to communicate up to its Activity, you can define an interface
+in the Fragment class and implement it within the Activity. The Fragment captures
+the interface implementation during its onAttach() lifecycle method and can then call
the Interface methods in order to communicate with the Activity.</p>
<p>Here is an example of Fragment to Activity communication:</p>
@@ -62,7 +62,7 @@
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
-
+
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
@@ -72,7 +72,7 @@
+ " must implement OnHeadlineSelectedListener");
}
}
-
+
...
}
</pre>
@@ -105,7 +105,7 @@
public static class MainActivity extends Activity
implements HeadlinesFragment.OnHeadlineSelectedListener{
...
-
+
public void onArticleSelected(int position) {
// The user selected the headline of an article from the HeadlinesFragment
// Do something here to display that article
@@ -118,12 +118,12 @@
<h2 id="Deliver">Deliver a Message to a Fragment</h2>
<p>The host activity can deliver messages to a fragment by capturing the {@link
-android.support.v4.app.Fragment} instance
+android.support.v4.app.Fragment} instance
with {@link android.support.v4.app.FragmentManager#findFragmentById findFragmentById()}, then
directly call the fragment's public methods.</p>
<p>For instance, imagine that the activity shown above may contain another fragment that's used to
-display the item specified by the data returned in the above callback method. In this case,
+display the item specified by the data returned in the above callback method. In this case,
the activity can pass the information received in the callback method to the other fragment that
will display the item:</p>
@@ -152,7 +152,7 @@
Bundle args = new Bundle();
args.putInt(ArticleFragment.ARG_POSITION, position);
newFragment.setArguments(args);
-
+
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
diff --git a/docs/html/training/basics/fragments/fragment-ui.jd b/docs/html/training/basics/fragments/fragment-ui.jd
index c0bd0a4..4cfec76 100644
--- a/docs/html/training/basics/fragments/fragment-ui.jd
+++ b/docs/html/training/basics/fragments/fragment-ui.jd
@@ -7,13 +7,13 @@
@jd:body
<div id="tb-wrapper">
- <div id="tb">
+ <div id="tb">
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#AddAtRuntime">Add a Fragment to an Activity at Runtime</a></li>
<li><a href="#Replace">Replace One Fragment with Another</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/components/fragments.html">Fragments</a></li>
@@ -52,14 +52,14 @@
-<h2 id="AddAtRuntime">Add a Fragment to an Activity at Runtime</h2>
+<h2 id="AddAtRuntime">Add a Fragment to an Activity at Runtime</h2>
<p>Rather than defining the fragments for an activity in the layout file—as shown in the
<a href="creating.html">previous lesson</a> with the {@code <fragment>} element—you can add
a fragment to the activity during the activity runtime. This is necessary
if you plan to change fragments during the life of the activity.</p>
-<p>To perform a transaction such as add or
+<p>To perform a transaction such as add or
remove a fragment, you must use the {@link android.support.v4.app.FragmentManager} to create a
{@link android.support.v4.app.FragmentTransaction}, which provides APIs to add, remove, replace,
and perform other fragment transactions.</p>
@@ -126,11 +126,11 @@
// Create a new Fragment to be placed in the activity layout
HeadlinesFragment firstFragment = new HeadlinesFragment();
-
+
// In case this activity was started with special instructions from an
// Intent, pass the Intent's extras to the fragment as arguments
firstFragment.setArguments(getIntent().getExtras());
-
+
// Add the fragment to the 'fragment_container' FrameLayout
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, firstFragment).commit();
diff --git a/docs/html/training/basics/fragments/index.jd b/docs/html/training/basics/fragments/index.jd
index aba6459..4fb71e4 100644
--- a/docs/html/training/basics/fragments/index.jd
+++ b/docs/html/training/basics/fragments/index.jd
@@ -56,7 +56,7 @@
devices running versions as old as Android 1.6.</p>
<h2>Lessons</h2>
-
+
<dl>
<dt><b><a href="creating.html">Creating a Fragment</a></b></dt>
<dd>Learn how to build a fragment and implement basic behaviors within its callback
@@ -67,5 +67,5 @@
<dt><b><a href="communicating.html">Communicating with Other Fragments</a></b></dt>
<dd>Learn how to set up communication paths from a fragment to the activity and other
fragments.</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/basics/network-ops/connecting.jd b/docs/html/training/basics/network-ops/connecting.jd
index 798a9ee7..9651269 100644
--- a/docs/html/training/basics/network-ops/connecting.jd
+++ b/docs/html/training/basics/network-ops/connecting.jd
@@ -7,8 +7,8 @@
next.link=managing.html
@jd:body
-
-<div id="tb-wrapper">
+
+<div id="tb-wrapper">
<div id="tb">
@@ -20,7 +20,7 @@
<li><a href="#AsyncTask">Perform Network Operations on a Separate Thread</a></li>
<li><a href="#download">Connect and Download Data</a></li>
<li><a href="#stream">Convert the InputStream to a String</a></li>
-
+
</ol>
<h2>You should also read</h2>
@@ -32,7 +32,7 @@
<li><a href="{@docRoot}guide/components/fundamentals.html">Application Fundamentals</a></li>
</ul>
-</div>
+</div>
</div>
<p>This lesson shows you how to implement a simple application that connects to
@@ -57,11 +57,11 @@
<h2 id="connection">Check the Network Connection</h2>
<p>Before your app attempts to connect to the network, it should check to see whether a
-network connection is available using
+network connection is available using
{@link android.net.ConnectivityManager#getActiveNetworkInfo getActiveNetworkInfo()}
-and {@link android.net.NetworkInfo#isConnected isConnected()}.
+and {@link android.net.NetworkInfo#isConnected isConnected()}.
Remember, the device may be out of range of a
-network, or the user may have disabled both Wi-Fi and mobile data access.
+network, or the user may have disabled both Wi-Fi and mobile data access.
For more discussion of this topic, see the lesson <a
href="{@docRoot}training/basics/network-ops/managing.html">Managing Network
Usage</a>.</p>
@@ -69,7 +69,7 @@
<pre>
public void myClickHandler(View view) {
...
- ConnectivityManager connMgr = (ConnectivityManager)
+ ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
@@ -98,28 +98,28 @@
{@link android.os.AsyncTask} methods:</p>
<ul>
-
+
<li>{@link android.os.AsyncTask#doInBackground doInBackground()} executes
the method <code>downloadUrl()</code>. It passes the web page URL as a
parameter. The method <code>downloadUrl()</code> fetches and processes the web
page content. When it finishes, it passes back a result string.</li>
-
+
<li>{@link android.os.AsyncTask#onPostExecute onPostExecute()} takes the
returned string and displays it in the UI.</li>
-
-
+
+
</ul>
-
+
<pre>
public class HttpExampleActivity extends Activity {
private static final String DEBUG_TAG = "HttpExample";
private EditText urlText;
private TextView textView;
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+ setContentView(R.layout.main);
urlText = (EditText) findViewById(R.id.myUrl);
textView = (TextView) findViewById(R.id.myText);
}
@@ -129,7 +129,7 @@
public void myClickHandler(View view) {
// Gets the URL from the UI's text field.
String stringUrl = urlText.getText().toString();
- ConnectivityManager connMgr = (ConnectivityManager)
+ ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
@@ -139,7 +139,7 @@
}
}
- // Uses AsyncTask to create a task away from the main UI thread. This task takes a
+ // Uses AsyncTask to create a task away from the main UI thread. This task takes a
// URL string and uses it to create an HttpUrlConnection. Once the connection
// has been established, the AsyncTask downloads the contents of the webpage as
// an InputStream. Finally, the InputStream is converted into a string, which is
@@ -147,7 +147,7 @@
private class DownloadWebpageTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
-
+
// params comes from the execute() call: params[0] is the url.
try {
return downloadUrl(urls[0]);
@@ -167,28 +167,28 @@
<p>The sequence of events in this snippet is as follows:</p>
<ol>
- <li>When users click the button that invokes {@code myClickHandler()},
+ <li>When users click the button that invokes {@code myClickHandler()},
the app passes
the specified URL to the {@link android.os.AsyncTask} subclass
<code>DownloadWebpageTask</code>.</li>
-
+
<li>The {@link android.os.AsyncTask} method {@link
-android.os.AsyncTask#doInBackground doInBackground()} calls the
+android.os.AsyncTask#doInBackground doInBackground()} calls the
<code>downloadUrl()</code> method. </li>
-
+
<li>The <code>downloadUrl()</code> method takes a URL string as a parameter
and uses it to create a {@link java.net.URL} object.</li>
-
+
<li>The {@link java.net.URL} object is used to establish an {@link
java.net.HttpURLConnection}.</li>
-
+
<li>Once the connection has been established, the {@link
java.net.HttpURLConnection} object fetches the web page content as an {@link
java.io.InputStream}.</li>
-
+
<li>The {@link java.io.InputStream} is passed to the <code>readIt()</code>
method, which converts the stream to a string.</li>
-
+
<li>Finally, the {@link android.os.AsyncTask}'s {@link
android.os.AsyncTask#onPostExecute onPostExecute()} method displays the string
in the main activity's UI.</li>
@@ -196,19 +196,19 @@
</ol>
<h2 id="download">Connect and Download Data</h2>
-
- <p>In your thread that performs your network transactions, you can use
- {@link java.net.HttpURLConnection} to perform a {@code GET} and download your data.
- After you call {@code connect()}, you can get an {@link java.io.InputStream} of the data
+
+ <p>In your thread that performs your network transactions, you can use
+ {@link java.net.HttpURLConnection} to perform a {@code GET} and download your data.
+ After you call {@code connect()}, you can get an {@link java.io.InputStream} of the data
by calling {@code getInputStream()}.
-
+
<p>In the following snippet, the {@link android.os.AsyncTask#doInBackground
doInBackground()} method calls the method <code>downloadUrl()</code>. The
<code>downloadUrl()</code> method takes the given URL and uses it to connect to
the network via {@link java.net.HttpURLConnection}. Once a connection has been
established, the app uses the method <code>getInputStream()</code> to retrieve
the data as an {@link java.io.InputStream}.</p>
-
+
<pre>
// Given a URL, establishes an HttpUrlConnection and retrieves
// the web page content as a InputStream, which it returns as
@@ -218,7 +218,7 @@
// Only display the first 500 characters of the retrieved
// web page content.
int len = 500;
-
+
try {
URL url = new URL(myurl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -235,13 +235,13 @@
// Convert the InputStream into a string
String contentAsString = readIt(is, len);
return contentAsString;
-
+
// Makes sure that the InputStream is closed after the app is
// finished using it.
} finally {
if (is != null) {
is.close();
- }
+ }
}
}</pre>
@@ -252,7 +252,7 @@
<h2 id="stream">Convert the InputStream to a String</h2>
-<p>An {@link java.io.InputStream} is a readable source of bytes. Once you get an {@link java.io.InputStream},
+<p>An {@link java.io.InputStream} is a readable source of bytes. Once you get an {@link java.io.InputStream},
it's common to decode or convert it into a
target data type. For example, if you were downloading image data, you might
decode and display it like this:</p>
@@ -271,7 +271,7 @@
<pre>// Reads an InputStream and converts it to a String.
public String readIt(InputStream stream, int len) throws IOException, UnsupportedEncodingException {
Reader reader = null;
- reader = new InputStreamReader(stream, "UTF-8");
+ reader = new InputStreamReader(stream, "UTF-8");
char[] buffer = new char[len];
reader.read(buffer);
return new String(buffer);
diff --git a/docs/html/training/basics/network-ops/index.jd b/docs/html/training/basics/network-ops/index.jd
index 1f6493f..1434562 100644
--- a/docs/html/training/basics/network-ops/index.jd
+++ b/docs/html/training/basics/network-ops/index.jd
@@ -42,7 +42,7 @@
<p>This class explains the basic tasks involved in connecting to the network,
monitoring the network connection (including connection changes), and giving
users control over an app's network usage. It also describes how to parse and
-consume XML data.</p>
+consume XML data.</p>
<p>This class includes a sample application that illustrates how to perform
common network operations. You can download the sample (to the right) and use it
@@ -66,18 +66,18 @@
<dl>
<dt><b><a href="connecting.html">Connecting to the Network</a></b></dt>
-
+
<dd>Learn how to connect to the network, choose an HTTP client, and perform
network operations outside of the UI thread.</dd>
<dt><b><a href="managing.html">Managing Network Usage</a></b></dt>
-
+
<dd>Learn how to check a
device's network connection, create a preferences UI for controlling network
usage, and respond to connection changes.</dd>
-
+
<dt><b><a href="xml.html">Parsing XML Data</a></b></dt>
<dd>Learn how to parse and consume XML data.</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/basics/network-ops/managing.jd b/docs/html/training/basics/network-ops/managing.jd
index a645b3f..2609db5 100644
--- a/docs/html/training/basics/network-ops/managing.jd
+++ b/docs/html/training/basics/network-ops/managing.jd
@@ -10,8 +10,8 @@
next.link=xml.html
@jd:body
-
-<div id="tb-wrapper">
+
+<div id="tb-wrapper">
<div id="tb">
<h2>This lesson teaches you to</h2>
@@ -37,7 +37,7 @@
<p class="filename">NetworkUsage.zip</p>
</div>
-</div>
+</div>
</div>
<p>This lesson describes how to write applications that have fine-grained
@@ -50,19 +50,19 @@
limits, because they can instead precisely control how much data your app
uses.</p>
-<p>For general guidelines on how to write apps that minimize the battery life
-impact of downloads and network connections, see
-<a href="{@docRoot}training/monitoring-device-state/index.html">Optimizing Battery Life</a>
+<p>For general guidelines on how to write apps that minimize the battery life
+impact of downloads and network connections, see
+<a href="{@docRoot}training/monitoring-device-state/index.html">Optimizing Battery Life</a>
and <a href="{@docRoot}training/efficient-downloads/index.html">Transferring Data Without Draining the Battery</a>.
<h2 id="check-connection">Check a Device's Network Connection</h2>
-<p>A device can have various types of network connections. This lesson
-focuses on using either a Wi-Fi or a mobile network connection. For the full
+<p>A device can have various types of network connections. This lesson
+focuses on using either a Wi-Fi or a mobile network connection. For the full
list of possible network types, see {@link android.net.ConnectivityManager}.<p>
<p>Wi-Fi is typically faster. Also, mobile data is often metered, which can get
-expensive.
+expensive.
A common strategy for apps is to only fetch large data
if a Wi-Fi network is available.</p>
@@ -77,11 +77,11 @@
<li>{@link android.net.ConnectivityManager}: Answers queries about the state
of network connectivity. It also notifies applications when network
connectivity changes. </li>
-
+
<li>{@link android.net.NetworkInfo}: Describes the status of a network
interface of a given type (currently either Mobile or Wi-Fi).
</li>
-
+
</ul>
@@ -94,16 +94,16 @@
<pre>
private static final String DEBUG_TAG = "NetworkStatusExample";
-...
-ConnectivityManager connMgr = (ConnectivityManager)
+...
+ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
-NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
boolean isWifiConn = networkInfo.isConnected();
networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
boolean isMobileConn = networkInfo.isConnected();
Log.d(DEBUG_TAG, "Wifi connected: " + isWifiConn);
Log.d(DEBUG_TAG, "Mobile connected: " + isMobileConn);
-</pre>
+</pre>
<p>Note that you should not base decisions on whether a network is
"available." You should always check {@link
@@ -122,7 +122,7 @@
<pre>
public boolean isOnline() {
- ConnectivityManager connMgr = (ConnectivityManager)
+ ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
@@ -148,37 +148,37 @@
</ul>
-<p>To write an app that supports network access and managing
-network usage, your manifest must have the right permissions and
+<p>To write an app that supports network access and managing
+network usage, your manifest must have the right permissions and
intent filters.
</p>
<ul>
<li>The manifest excerpted below includes the following permissions:
<ul>
-
+
<li>{@link android.Manifest.permission#INTERNET
android.permission.INTERNET}—Allows applications to open network
sockets.</li>
-
+
<li>{@link android.Manifest.permission#ACCESS_NETWORK_STATE
android.permission.ACCESS_NETWORK_STATE}—Allows applications to access
information about networks.</li>
-
+
</ul>
</li>
-
- <li>You can declare the intent filter for the
+
+ <li>You can declare the intent filter for the
{@link android.content.Intent#ACTION_MANAGE_NETWORK_USAGE} action (introduced in
Android 4.0) to indicate that your application defines an activity that offers
options to control data usage. {@link
android.content.Intent#ACTION_MANAGE_NETWORK_USAGE} shows settings for managing
-the network data usage of a specific application. When your app has a settings activity
-that allows users to control network usage, you should declare this intent filter for that activity.
+the network data usage of a specific application. When your app has a settings activity
+that allows users to control network usage, you should declare this intent filter for that activity.
In the sample application, this action is handled by the class
<code>SettingsActivity</code>, which displays a preferences UI to let users
decide when to download a feed.</li>
-
+
</ul>
@@ -188,9 +188,9 @@
package="com.example.android.networkusage"
...>
- <uses-sdk android:minSdkVersion="4"
+ <uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="14" />
-
+
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@@ -213,7 +213,7 @@
<code>SettingsActivity</code> has an intent filter for the {@link
android.content.Intent#ACTION_MANAGE_NETWORK_USAGE} action.
<code>SettingsActivity</code> is a subclass of {@link
-android.preference.PreferenceActivity}. It displays a preferences screen
+android.preference.PreferenceActivity}. It displays a preferences screen
(shown in figure 1) that
lets users specify the following:</p>
@@ -221,10 +221,10 @@
<li>Whether to display summaries for each XML feed entry, or just a link for
each entry.</li>
-
+
<li>Whether to download the XML feed if any network connection is available,
or only if Wi-Fi is available.</li>
-
+
</ul>
<img src="{@docRoot}images/training/basics/network-settings1.png" alt="Preferences panel" />
@@ -232,49 +232,49 @@
<img src="{@docRoot}images/training/basics/network-settings2.png" alt="Setting a network preference" />
<p class="img-caption"><strong>Figure 1.</strong> Preferences activity.</p>
-<p>Here is <code>SettingsActivity</code>. Note that it implements
-{@link android.content.SharedPreferences.OnSharedPreferenceChangeListener OnSharedPreferenceChangeListener}.
+<p>Here is <code>SettingsActivity</code>. Note that it implements
+{@link android.content.SharedPreferences.OnSharedPreferenceChangeListener OnSharedPreferenceChangeListener}.
When a user changes a preference, it fires
-{@link android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged onSharedPreferenceChanged()},
-which sets {@code refreshDisplay} to true. This causes the display to refresh when the user
+{@link android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged onSharedPreferenceChanged()},
+which sets {@code refreshDisplay} to true. This causes the display to refresh when the user
returns to the main activity:</p>
<pre>public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
// Loads the XML preferences file
addPreferencesFromResource(R.xml.preferences);
}
-
+
@Override
protected void onResume() {
super.onResume();
- // Registers a listener whenever a key changes
+ // Registers a listener whenever a key changes
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
-
+
@Override
protected void onPause() {
super.onPause();
// Unregisters the listener set in onResume().
- // It's best practice to unregister listeners when your app isn't using them to cut down on
- // unnecessary system overhead. You do this in onPause().
- getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
+ // It's best practice to unregister listeners when your app isn't using them to cut down on
+ // unnecessary system overhead. You do this in onPause().
+ getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
-
- // When the user changes the preferences selection,
+
+ // When the user changes the preferences selection,
// onSharedPreferenceChanged() restarts the main activity as a new
// task. Sets the refreshDisplay flag to "true" to indicate that
// the main activity should update its display.
// The main activity queries the PreferenceManager to get the latest settings.
-
+
@Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// Sets refreshDisplay to true so that when the user returns to the main
// activity, the display refreshes to reflect the new settings.
NetworkActivity.refreshDisplay = true;
@@ -295,31 +295,31 @@
public static final String WIFI = "Wi-Fi";
public static final String ANY = "Any";
private static final String URL = "http://stackoverflow.com/feeds/tag?tagnames=android&sort=newest";
-
+
// Whether there is a Wi-Fi connection.
- private static boolean wifiConnected = false;
+ private static boolean wifiConnected = false;
// Whether there is a mobile connection.
private static boolean mobileConnected = false;
// Whether the display should be refreshed.
public static boolean refreshDisplay = true;
-
+
// The user's current network preference setting.
public static String sPref = null;
-
+
// The BroadcastReceiver that tracks network connectivity changes.
private NetworkReceiver receiver = new NetworkReceiver();
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
// Registers BroadcastReceiver to track network connection changes.
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
receiver = new NetworkReceiver();
this.registerReceiver(receiver, filter);
}
-
- @Override
+
+ @Override
public void onDestroy() {
super.onDestroy();
// Unregisters BroadcastReceiver when app is destroyed.
@@ -327,34 +327,34 @@
this.unregisterReceiver(receiver);
}
}
-
+
// Refreshes the display if the network connection and the
// pref settings allow it.
-
+
@Override
public void onStart () {
- super.onStart();
-
+ super.onStart();
+
// Gets the user's network preference settings
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
-
+
// Retrieves a string value for the preferences. The second parameter
// is the default value to use if a preference value is not found.
sPref = sharedPrefs.getString("listPref", "Wi-Fi");
- updateConnectedFlags();
-
+ updateConnectedFlags();
+
if(refreshDisplay){
- loadPage();
+ loadPage();
}
}
-
+
// Checks the network connection and sets the wifiConnected and mobileConnected
- // variables accordingly.
+ // variables accordingly.
public void updateConnectedFlags() {
- ConnectivityManager connMgr = (ConnectivityManager)
+ ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
-
+
NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();
if (activeInfo != null && activeInfo.isConnected()) {
wifiConnected = activeInfo.getType() == ConnectivityManager.TYPE_WIFI;
@@ -362,9 +362,9 @@
} else {
wifiConnected = false;
mobileConnected = false;
- }
+ }
}
-
+
// Uses AsyncTask subclass to download the XML feed from stackoverflow.com.
public void loadPage() {
if (((sPref.equals(ANY)) && (wifiConnected || mobileConnected))
@@ -376,7 +376,7 @@
}
}
...
-
+
}</pre>
<h2 id="detect-changes">Detect Connection Changes</h2>
@@ -388,36 +388,36 @@
determines what the network connection status is, and sets the flags
<code>wifiConnected</code> and <code>mobileConnected</code> to true/false
accordingly. The upshot is that the next time the user returns to the app, the
-app will only download the latest feed and update the display if
+app will only download the latest feed and update the display if
<code>NetworkActivity.refreshDisplay</code> is set to <code>true</code>.</p>
-<p>Setting up a BroadcastReceiver that gets called unnecessarily can be a
+<p>Setting up a BroadcastReceiver that gets called unnecessarily can be a
drain on system resources.
-The sample application registers the
-{@link android.content.BroadcastReceiver} {@code NetworkReceiver} in
-{@link android.app.Activity#onCreate(android.os.Bundle) onCreate()},
-and it unregisters it in
-{@link android.app.Activity#onDestroy onDestroy()}. This is more lightweight
+The sample application registers the
+{@link android.content.BroadcastReceiver} {@code NetworkReceiver} in
+{@link android.app.Activity#onCreate(android.os.Bundle) onCreate()},
+and it unregisters it in
+{@link android.app.Activity#onDestroy onDestroy()}. This is more lightweight
than declaring a {@code <receiver>} in the manifest. When you declare a
{@code <receiver>} in the manifest, it can wake up your app at any time,
-even if you haven't run it for weeks. By registering and unregistering
-{@code NetworkReceiver} within the main activity, you ensure that the app won't
-be woken up after the user leaves the app.
+even if you haven't run it for weeks. By registering and unregistering
+{@code NetworkReceiver} within the main activity, you ensure that the app won't
+be woken up after the user leaves the app.
If you do declare a {@code <receiver>} in the manifest and you know exactly
-where you need it, you can use
+where you need it, you can use
{@link android.content.pm.PackageManager#setComponentEnabledSetting setComponentEnabledSetting()}
to enable and disable it as appropriate.</p>
<p>Here is <code>NetworkReceiver</code>:</p>
-<pre>public class NetworkReceiver extends BroadcastReceiver {
-
+<pre>public class NetworkReceiver extends BroadcastReceiver {
+
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager conn = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = conn.getActiveNetworkInfo();
-
+
// Checks the user prefs and the network connection. Based on the result, decides whether
// to refresh the display or keep the current display.
// If the userpref is Wi-Fi only, checks to see if the device has a Wi-Fi connection.
@@ -432,9 +432,9 @@
// (which by process of elimination would be mobile), sets refreshDisplay to true.
} else if (ANY.equals(sPref) && networkInfo != null) {
refreshDisplay = true;
-
+
// Otherwise, the app can't download content--either because there is no network
- // connection (mobile or Wi-Fi), or because the pref setting is WIFI, and there
+ // connection (mobile or Wi-Fi), or because the pref setting is WIFI, and there
// is no Wi-Fi connection.
// Sets refreshDisplay to false.
} else {
diff --git a/docs/html/training/basics/network-ops/xml.jd b/docs/html/training/basics/network-ops/xml.jd
index 0ea696d..3385a63 100644
--- a/docs/html/training/basics/network-ops/xml.jd
+++ b/docs/html/training/basics/network-ops/xml.jd
@@ -9,7 +9,7 @@
@jd:body
-<div id="tb-wrapper">
+<div id="tb-wrapper">
<div id="tb">
@@ -38,7 +38,7 @@
<p class="filename">NetworkUsage.zip</p>
</div>
-</div>
+</div>
</div>
<p>Extensible Markup Language (XML) is a set of rules for encoding documents in
@@ -55,11 +55,11 @@
implementations of this interface:</p>
<ul>
- <li><a href="http://kxml.sourceforge.net/"><code>KXmlParser</code></a>
- via {@link org.xmlpull.v1.XmlPullParserFactory#newPullParser XmlPullParserFactory.newPullParser()}.
+ <li><a href="http://kxml.sourceforge.net/"><code>KXmlParser</code></a>
+ via {@link org.xmlpull.v1.XmlPullParserFactory#newPullParser XmlPullParserFactory.newPullParser()}.
</li>
- <li><code>ExpatPullParser</code>, via
- {@link android.util.Xml#newPullParser Xml.newPullParser()}.
+ <li><code>ExpatPullParser</code>, via
+ {@link android.util.Xml#newPullParser Xml.newPullParser()}.
</li>
</ul>
@@ -69,15 +69,15 @@
<h2 id="analyze">Analyze the Feed</h2>
-<p>The first step in parsing a feed is to decide which fields you're interested in.
+<p>The first step in parsing a feed is to decide which fields you're interested in.
The parser extracts data for those fields and ignores the rest.</p>
<p>Here is an excerpt from the feed that's being parsed in the sample app. Each
post to <a href="http://stackoverflow.com">StackOverflow.com</a> appears in the
feed as an <code>entry</code> tag that contains several nested tags:</p>
-<pre><?xml version="1.0" encoding="utf-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" ...">
+<pre><?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" ...">
<title type="text">newest questions tagged android - Stack Overflow</title>
...
<entry>
@@ -107,7 +107,7 @@
...
</feed></pre>
-<p>The sample app
+<p>The sample app
extracts data for the <code>entry</code> tag and its nested tags
<code>title</code>, <code>link</code>, and <code>summary</code>.</p>
@@ -125,7 +125,7 @@
<pre>public class StackOverflowXmlParser {
// We don't use namespaces
private static final String ns = null;
-
+
public List<Entry> parse(InputStream in) throws XmlPullParserException, IOException {
try {
XmlPullParser parser = Xml.newPullParser();
@@ -137,7 +137,7 @@
in.close();
}
}
- ...
+ ...
}</pre>
<h2 id="read">Read the Feed</h2>
@@ -166,7 +166,7 @@
} else {
skip(parser);
}
- }
+ }
return entries;
}</pre>
@@ -187,7 +187,7 @@
<li>A "read" method for each tag you're interested in. For example,
<code>readEntry()</code>, <code>readTitle()</code>, and so on. The parser reads
-tags from the input stream. When it encounters a tag named <code>entry</code>,
+tags from the input stream. When it encounters a tag named <code>entry</code>,
<code>title</code>,
<code>link</code> or <code>summary</code>, it calls the appropriate method
for that tag. Otherwise, it skips the tag.
@@ -201,7 +201,7 @@
<code>readText()</code>. This method extracts data for these tags by calling
<code>parser.getText()</code>.</li>
-<li>For the <code>link</code> tag, the parser extracts data for links by first
+<li>For the <code>link</code> tag, the parser extracts data for links by first
determining if the link is the kind
it's interested in. Then it uses <code>parser.getAttributeValue()</code> to
extract the link's value.</li>
@@ -215,7 +215,7 @@
</li>
<li>A helper <code>skip()</code> method that's recursive. For more discussion of this topic, see <a href="#skip">Skip Tags You Don't Care About</a>.</li>
</ul>
-
+
</li>
</ol>
@@ -231,7 +231,7 @@
this.link = link;
}
}
-
+
// Parses the contents of an entry. If it encounters a title, summary, or link tag, hands them off
// to their respective "read" methods for processing. Otherwise, skips the tag.
private Entry readEntry(XmlPullParser parser) throws XmlPullParserException, IOException {
@@ -264,18 +264,18 @@
parser.require(XmlPullParser.END_TAG, ns, "title");
return title;
}
-
+
// Processes link tags in the feed.
private String readLink(XmlPullParser parser) throws IOException, XmlPullParserException {
String link = "";
parser.require(XmlPullParser.START_TAG, ns, "link");
String tag = parser.getName();
- String relType = parser.getAttributeValue(null, "rel");
+ String relType = parser.getAttributeValue(null, "rel");
if (tag.equals("link")) {
if (relType.equals("alternate")){
link = parser.getAttributeValue(null, "href");
parser.nextTag();
- }
+ }
}
parser.require(XmlPullParser.END_TAG, ns, "link");
return link;
@@ -350,7 +350,7 @@
<ul>
<li>The first time through the <code>while</code> loop, the next tag the parser
-encounters after <code><author></code> is the <code>START_TAG</code> for
+encounters after <code><author></code> is the <code>START_TAG</code> for
<code><name></code>. The value for <code>depth</code> is incremented to
2.</li>
@@ -367,7 +367,7 @@
<code>depth</code> is decremented to 1.</li>
<li>The fifth time and final time through the <code>while</code> loop, the next
-tag the parser encounters is the <code>END_TAG</code>
+tag the parser encounters is the <code>END_TAG</code>
<code></author></code>. The value for <code>depth</code> is decremented to
0, indicating that the <code><author></code> element has been successfully
skipped.</li>
@@ -377,7 +377,7 @@
<h2 id="consume">Consume XML Data</h2>
<p>The example application fetches and parses the XML feed within an {@link
-android.os.AsyncTask}. This takes the processing off the main UI thread. When
+android.os.AsyncTask}. This takes the processing off the main UI thread. When
processing is complete, the app updates the UI in the main activity
(<code>NetworkActivity</code>).</p>
<p>In the excerpt shown below, the <code>loadPage()</code> method does the
@@ -386,33 +386,33 @@
<ul>
<li>Initializes a string variable with the URL for the XML feed.</li>
-
+
<li>If the user's settings and the network connection allow it, invokes
-<code>new DownloadXmlTask().execute(url)</code>. This instantiates a new
+<code>new DownloadXmlTask().execute(url)</code>. This instantiates a new
<code>DownloadXmlTask</code> object ({@link android.os.AsyncTask} subclass) and
runs its {@link android.os.AsyncTask#execute execute()} method, which downloads
and parses the feed and returns a string result to be displayed in the UI.</li>
-
+
</ul>
<pre>
public class NetworkActivity extends Activity {
public static final String WIFI = "Wi-Fi";
public static final String ANY = "Any";
private static final String URL = "http://stackoverflow.com/feeds/tag?tagnames=android&sort=newest";
-
+
// Whether there is a Wi-Fi connection.
- private static boolean wifiConnected = false;
+ private static boolean wifiConnected = false;
// Whether there is a mobile connection.
private static boolean mobileConnected = false;
// Whether the display should be refreshed.
- public static boolean refreshDisplay = true;
+ public static boolean refreshDisplay = true;
public static String sPref = null;
...
-
+
// Uses AsyncTask to download the XML feed from stackoverflow.com.
- public void loadPage() {
-
+ public void loadPage() {
+
if((sPref.equals(ANY)) && (wifiConnected || mobileConnected)) {
new DownloadXmlTask().execute(URL);
}
@@ -420,25 +420,25 @@
new DownloadXmlTask().execute(URL);
} else {
// show error
- }
+ }
}</pre>
-
+
<p>The {@link android.os.AsyncTask} subclass shown below,
<code>DownloadXmlTask</code>, implements the following {@link
android.os.AsyncTask} methods:</p>
<ul>
-
+
<li>{@link android.os.AsyncTask#doInBackground doInBackground()} executes
the method <code>loadXmlFromNetwork()</code>. It passes the feed URL as a
parameter. The method <code>loadXmlFromNetwork()</code> fetches and processes
the feed. When it finishes, it passes back a result string.</li>
-
+
<li>{@link android.os.AsyncTask#onPostExecute onPostExecute()} takes the
returned string and displays it in the UI.</li>
-
+
</ul>
-
+
<pre>
// Implementation of AsyncTask used to download XML feed from stackoverflow.com.
private class DownloadXmlTask extends AsyncTask<String, Void, String> {
@@ -454,7 +454,7 @@
}
@Override
- protected void onPostExecute(String result) {
+ protected void onPostExecute(String result) {
setContentView(R.layout.main);
// Displays the HTML string in the UI via a WebView
WebView myWebView = (WebView) findViewById(R.id.webview);
@@ -464,28 +464,28 @@
<p>Below is the method <code>loadXmlFromNetwork()</code> that is invoked from
<code>DownloadXmlTask</code>. It does the following:</p>
-
+
<ol>
-
+
<li>Instantiates a <code>StackOverflowXmlParser</code>. It also creates variables for
-a {@link java.util.List} of <code>Entry</code> objects (<code>entries</code>), and
+a {@link java.util.List} of <code>Entry</code> objects (<code>entries</code>), and
<code>title</code>, <code>url</code>, and <code>summary</code>, to hold the
values extracted from the XML feed for those fields.</li>
-
- <li>Calls <code>downloadUrl()</code>, which fetches the feed and returns it as
+
+ <li>Calls <code>downloadUrl()</code>, which fetches the feed and returns it as
an {@link java.io.InputStream}.</li>
-
- <li>Uses <code>StackOverflowXmlParser</code> to parse the {@link java.io.InputStream}.
- <code>StackOverflowXmlParser</code> populates a
+
+ <li>Uses <code>StackOverflowXmlParser</code> to parse the {@link java.io.InputStream}.
+ <code>StackOverflowXmlParser</code> populates a
{@link java.util.List} of <code>entries</code> with data from the feed.</li>
-
- <li>Processes the <code>entries</code> {@link java.util.List},
+
+ <li>Processes the <code>entries</code> {@link java.util.List},
and combines the feed data with HTML markup.</li>
-
+
<li>Returns an HTML string that is displayed in the main activity
UI by the {@link android.os.AsyncTask} method {@link
android.os.AsyncTask#onPostExecute onPostExecute()}.</li>
-
+
</ol>
<pre>
@@ -499,35 +499,35 @@
String title = null;
String url = null;
String summary = null;
- Calendar rightNow = Calendar.getInstance();
+ Calendar rightNow = Calendar.getInstance();
DateFormat formatter = new SimpleDateFormat("MMM dd h:mmaa");
-
+
// Checks whether the user set the preference to include summary text
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean pref = sharedPrefs.getBoolean("summaryPref", false);
-
+
StringBuilder htmlString = new StringBuilder();
htmlString.append("<h3>" + getResources().getString(R.string.page_title) + "</h3>");
- htmlString.append("<em>" + getResources().getString(R.string.updated) + " " +
+ htmlString.append("<em>" + getResources().getString(R.string.updated) + " " +
formatter.format(rightNow.getTime()) + "</em>");
-
+
try {
- stream = downloadUrl(urlString);
+ stream = downloadUrl(urlString);
entries = stackOverflowXmlParser.parse(stream);
// Makes sure that the InputStream is closed after the app is
// finished using it.
} finally {
if (stream != null) {
stream.close();
- }
+ }
}
-
+
// StackOverflowXmlParser returns a List (called "entries") of Entry objects.
// Each Entry object represents a single post in the XML feed.
// This section processes the entries list to combine each entry with HTML markup.
// Each entry is displayed in the UI as a link that optionally includes
// a text summary.
- for (Entry entry : entries) {
+ for (Entry entry : entries) {
htmlString.append("<p><a href='");
htmlString.append(entry.link);
htmlString.append("'>" + entry.title + "</a></p>");
diff --git a/docs/html/training/basics/supporting-devices/index.jd b/docs/html/training/basics/supporting-devices/index.jd
index 4644c31..c9f2e6c 100644
--- a/docs/html/training/basics/supporting-devices/index.jd
+++ b/docs/html/training/basics/supporting-devices/index.jd
@@ -35,7 +35,7 @@
variety of Android-compatible devices, using a single application package (APK).</p>
<h2>Lessons</h2>
-
+
<dl>
<dt><b><a href="languages.html">Supporting Different Languages</a></b></dt>
<dd>Learn how to support multiple languages with alternative string resources.</dd>
@@ -44,5 +44,5 @@
<dt><b><a href="platforms.html">Supporting Different Platform Versions</a></b></dt>
<dd>Learn how to use APIs available in new versions of Android while continuing to support
older versions of Android.</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/basics/supporting-devices/languages.jd b/docs/html/training/basics/supporting-devices/languages.jd
index ba7c016..0ad1faf 100644
--- a/docs/html/training/basics/supporting-devices/languages.jd
+++ b/docs/html/training/basics/supporting-devices/languages.jd
@@ -36,7 +36,7 @@
your string values.</p>
-<h2 id="CreateDirs">Create Locale Directories and String Files</h2>
+<h2 id="CreateDirs">Create Locale Directories and String Files</h2>
<p>To add support for more languages, create additional <code>values</code> directories inside
<code>res/</code> that include a hyphen and the ISO language code at the end of the
@@ -63,7 +63,7 @@
<p>At runtime, the Android system uses the appropriate set of string resources based on the
locale currently set for the user's device.</p>
-
+
<p>For example, the following are some different string resource files for different languages.</p>
@@ -112,7 +112,7 @@
<p>In your source code, you can refer to a string resource with the syntax {@code
R.string.<string_name>}. There are a variety of methods that accept a string resource this
way.</p>
-
+
<p>For example:</p>
<pre>
diff --git a/docs/html/training/basics/supporting-devices/platforms.jd b/docs/html/training/basics/supporting-devices/platforms.jd
index eecb356..6712029 100644
--- a/docs/html/training/basics/supporting-devices/platforms.jd
+++ b/docs/html/training/basics/supporting-devices/platforms.jd
@@ -10,14 +10,14 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#sdk-versions">Specify Minimum and Target API Levels</a></li>
<li><a href="#version-codes">Check System Version at Runtime</a></li>
<li><a href="#style-themes">Use Platform Styles and Themes</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">Android API Levels</a></li>
@@ -27,19 +27,19 @@
</div>
</div>
-<p>While the latest versions of Android often provide great APIs for your app, you should continue
-to support older versions of Android until more devices get updated. This
-lesson shows you how to take advantage of the latest APIs while continuing to support older
+<p>While the latest versions of Android often provide great APIs for your app, you should continue
+to support older versions of Android until more devices get updated. This
+lesson shows you how to take advantage of the latest APIs while continuing to support older
versions as well.</p>
<p>The dashboard for <a
href="http://developer.android.com/about/dashboards/index.html">Platform Versions</a>
-is updated regularly to show the distribution of active
-devices running each version of Android, based on the number of devices that visit the Google Play
-Store. Generally, it’s a good practice to support about 90% of the active devices, while
+is updated regularly to show the distribution of active
+devices running each version of Android, based on the number of devices that visit the Google Play
+Store. Generally, it’s a good practice to support about 90% of the active devices, while
targeting your app to the latest version.</p>
-<p class="note"><strong>Tip:</strong> In order to provide the best features and
+<p class="note"><strong>Tip:</strong> In order to provide the best features and
functionality across several Android versions, you should use the <a
href="{@docRoot}tools/support-library/index.html">Android Support Library</a> in your app,
which allows you to use several recent platform APIs on older versions.</p>
@@ -49,8 +49,8 @@
<h2 id="sdk-versions">Specify Minimum and Target API Levels</h2>
<p>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">AndroidManifest.xml</a> file
-describes details about your app and
-identifies which versions of Android it supports. Specifically, the <code>minSdkVersion</code>
+describes details about your app and
+identifies which versions of Android it supports. Specifically, the <code>minSdkVersion</code>
and <code>targetSdkVersion</code> attributes for the <a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element
identify the lowest API level with which your app is compatible and the highest API level against
@@ -65,9 +65,9 @@
</manifest>
</pre>
-<p>As new versions of Android are released, some style and behaviors may change.
+<p>As new versions of Android are released, some style and behaviors may change.
To allow your app to take advantage of these changes and ensure that your app fits the style of
-each user's device, you should set the
+each user's device, you should set the
<a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a>
value to match the latest Android version
@@ -93,24 +93,24 @@
-<p class="note"><strong>Note:</strong> When parsing XML resources, Android ignores XML
+<p class="note"><strong>Note:</strong> When parsing XML resources, Android ignores XML
attributes that aren’t supported by the current device. So you can safely use XML attributes that
are only supported by newer versions without worrying about older versions breaking when they
-encounter that code. For example, if you set the
+encounter that code. For example, if you set the
<code>targetSdkVersion="11"</code>, your app includes the {@link android.app.ActionBar} by default
-on Android 3.0 and higher. To then add menu items to the action bar, you need to set
-<code>android:showAsAction="ifRoom"</code> in your menu resource XML. It's safe to do this
-in a cross-version XML file, because the older versions of Android simply ignore the
-<code>showAsAction</code> attribute (that is, you <em>do not</em> need a separate
+on Android 3.0 and higher. To then add menu items to the action bar, you need to set
+<code>android:showAsAction="ifRoom"</code> in your menu resource XML. It's safe to do this
+in a cross-version XML file, because the older versions of Android simply ignore the
+<code>showAsAction</code> attribute (that is, you <em>do not</em> need a separate
version in <code>res/menu-v11/</code>).</p>
-<h2 id="style-themes">Use Platform Styles and Themes</h2>
+<h2 id="style-themes">Use Platform Styles and Themes</h2>
-<p>Android provides user experience themes that give apps the look and feel of the
-underlying operating system. These themes can be applied to your app within the
-manifest file. By using these built in styles and themes, your app will
+<p>Android provides user experience themes that give apps the look and feel of the
+underlying operating system. These themes can be applied to your app within the
+manifest file. By using these built in styles and themes, your app will
naturally follow the latest look and feel of Android with each new release.</p>
<p>To make your activity look like a dialog box:</p>
@@ -126,7 +126,7 @@
<pre><activity android:theme="@style/CustomTheme"></pre>
<p>To apply a theme to your entire app (all activities), add the <code>android:theme</code>
-attribute
+attribute
to the <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code
<application>}</a> element:</p>
diff --git a/docs/html/training/basics/supporting-devices/screens.jd b/docs/html/training/basics/supporting-devices/screens.jd
index 4b54de8..9d5e7c1 100644
--- a/docs/html/training/basics/supporting-devices/screens.jd
+++ b/docs/html/training/basics/supporting-devices/screens.jd
@@ -8,13 +8,13 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#create-layouts">Create Different Layouts</a></li>
<li><a href="#create-bitmaps">Create Different Bitmaps</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}training/multiscreen/index.html">Designing for Multiple
@@ -26,9 +26,9 @@
</div>
</div>
-<p>Android categorizes device screens using two general properties: size and density. You should
-expect that your app will be installed on devices with screens that range in both size
-and density. As such, you should include some alternative resources that optimize your app’s
+<p>Android categorizes device screens using two general properties: size and density. You should
+expect that your app will be installed on devices with screens that range in both size
+and density. As such, you should include some alternative resources that optimize your app’s
appearance for different screen sizes and densities.</p>
<ul>
@@ -46,12 +46,12 @@
orientation.</p>
-<h2 id="create-layouts">Create Different Layouts</h2>
+<h2 id="create-layouts">Create Different Layouts</h2>
<p>To optimize your user experience on different screen sizes, you should create a unique layout XML
-file for each screen size you want to support. Each layout should be
-saved into the appropriate resources directory, named with a <code>-<screen_size></code>
-suffix. For example, a unique layout for large screens should be saved under
+file for each screen size you want to support. Each layout should be
+saved into the appropriate resources directory, named with a <code>-<screen_size></code>
+suffix. For example, a unique layout for large screens should be saved under
<code>res/layout-large/</code>.</p>
<p class="note"><strong>Note:</strong> Android automatically scales your layout in order to
@@ -85,7 +85,7 @@
}
</pre>
-<p>The system loads the layout file from the appropriate layout directory based on screen size of
+<p>The system loads the layout file from the appropriate layout directory based on screen size of
the device on which your app is running. More information about how Android selects the
appropriate resource is available in the <a
href="{@docRoot}guide/topics/resources/providing-resources.html#BestMatch">Providing Resources</a>
@@ -120,7 +120,7 @@
main.xml
</pre>
-<p class="note"><strong>Note:</strong> Android 3.2 and above supports an advanced method of
+<p class="note"><strong>Note:</strong> Android 3.2 and above supports an advanced method of
defining screen sizes that allows you to specify resources for screen sizes based on
the minimum width and height in terms of density-independent pixels. This lesson does not cover
this new technique. For more information, read <a
@@ -128,14 +128,14 @@
Screens</a>.</p>
-
+
<h2 id="create-bitmaps">Create Different Bitmaps</h2>
<p>You should always provide bitmap resources that are properly scaled to each of the generalized
density buckets: low, medium, high and extra-high density. This helps you achieve good graphical
quality and performance on all screen densities.</p>
-<p>To generate these images, you should start with your raw resource in vector format and generate
+<p>To generate these images, you should start with your raw resource in vector format and generate
the images for each density using the following size scale:</p>
<ul>
<li>xhdpi: 2.0</li>
@@ -144,7 +144,7 @@
<li>ldpi: 0.75</li>
</ul>
-<p>This means that if you generate a 200x200 image for xhdpi devices, you should generate the same
+<p>This means that if you generate a 200x200 image for xhdpi devices, you should generate the same
resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.</p>
<p>Then, place the files in the appropriate drawable resource directory:</p>
@@ -162,14 +162,14 @@
awesomeimage.png
</pre>
-<p>Any time you reference <code>@drawable/awesomeimage</code>, the system selects the
+<p>Any time you reference <code>@drawable/awesomeimage</code>, the system selects the
appropriate bitmap based on the screen's density.</p>
<p class="note"><strong>Note:</strong> Low-density (ldpi) resources aren’t always necessary. When
you provide hdpi assets, the system scales them down by one half to properly fit ldpi
screens.</p>
-<p>For more tips and guidelines about creating icon assets for your app, see the
+<p>For more tips and guidelines about creating icon assets for your app, see the
<a href="{@docRoot}design/style/iconography.html">Iconography design guide</a>.</p>
diff --git a/docs/html/training/building-userinfo.jd b/docs/html/training/building-userinfo.jd
index 40e5b94..a08899d 100644
--- a/docs/html/training/building-userinfo.jd
+++ b/docs/html/training/building-userinfo.jd
@@ -4,6 +4,6 @@
@jd:body
-<p>These lessons teach you how to include contact information and authenticate users with the same
-credentials they use for Google. These features allow your app to connect users with people they
+<p>These lessons teach you how to include contact information and authenticate users with the same
+credentials they use for Google. These features allow your app to connect users with people they
care about and provide a personalized experience without creating new user accounts.</p>
diff --git a/docs/html/training/camera/cameradirect.jd b/docs/html/training/camera/cameradirect.jd
index 6f358a5..851c7db 100644
--- a/docs/html/training/camera/cameradirect.jd
+++ b/docs/html/training/camera/cameradirect.jd
@@ -11,7 +11,7 @@
<div id="tb-wrapper">
<div id="tb">
-
+
<h2>This lesson teaches you to</h2>
<ol>
<li><a href="#TaskOpenCamera">Open the Camera Object</a></li>
@@ -22,7 +22,7 @@
<li><a href="#TaskRestartPreview">Restart the Preview</a></li>
<li><a href="#TaskReleaseCamera">Stop the Preview and Release the Camera</a></li>
</ol>
-
+
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}guide/topics/media/camera.html#custom-camera">Building
@@ -57,7 +57,7 @@
<pre>
private boolean safeCameraOpen(int id) {
boolean qOpened = false;
-
+
try {
releaseCameraAndPreview();
mCamera = Camera.open(id);
@@ -67,7 +67,7 @@
e.printStackTrace();
}
- return qOpened;
+ return qOpened;
}
private void releaseCameraAndPreview() {
@@ -136,22 +136,22 @@
<pre>
public void setCamera(Camera camera) {
if (mCamera == camera) { return; }
-
+
stopPreviewAndFreeCamera();
-
+
mCamera = camera;
-
+
if (mCamera != null) {
List<Size> localSizes = mCamera.getParameters().getSupportedPreviewSizes();
mSupportedPreviewSizes = localSizes;
requestLayout();
-
+
try {
mCamera.setPreviewDisplay(mHolder);
} catch (IOException e) {
e.printStackTrace();
}
-
+
// Important: Call startPreview() to start updating the preview
// surface. Preview must be started before you can take a picture.
mCamera.startPreview();
@@ -260,12 +260,12 @@
if (mCamera != null) {
// Call stopPreview() to stop updating the preview surface.
mCamera.stopPreview();
-
+
// Important: Call release() to release the camera for use by other
// applications. Applications should release the camera immediately
// during onPause() and re-open() it during onResume()).
mCamera.release();
-
+
mCamera = null;
}
}
diff --git a/docs/html/training/contacts-provider/display-contact-badge.jd b/docs/html/training/contacts-provider/display-contact-badge.jd
index b00ce0e..6c9616b 100644
--- a/docs/html/training/contacts-provider/display-contact-badge.jd
+++ b/docs/html/training/contacts-provider/display-contact-badge.jd
@@ -268,7 +268,7 @@
Uri.withAppendedPath(
contactUri, Photo.CONTENT_DIRECTORY);
}
-
+
/*
* Retrieves an AssetFileDescriptor object for the thumbnail
* URI
diff --git a/docs/html/training/contacts-provider/index.jd b/docs/html/training/contacts-provider/index.jd
index f380d95..9562977 100644
--- a/docs/html/training/contacts-provider/index.jd
+++ b/docs/html/training/contacts-provider/index.jd
@@ -55,7 +55,7 @@
<a href="{@docRoot}guide/topics/providers/contacts-provider.html">Contacts Provider</a>.
</p>
<h2>Lessons</h2>
-
+
<dl>
<dt>
<b><a href="retrieve-names.html">Retrieving a List of Contacts</a></b>
diff --git a/docs/html/training/custom-views/index.jd b/docs/html/training/custom-views/index.jd
index 447da94..d249fbd 100755
--- a/docs/html/training/custom-views/index.jd
+++ b/docs/html/training/custom-views/index.jd
@@ -67,7 +67,7 @@
custom drawings run faster.
</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/displaying-bitmaps/cache-bitmap.jd b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
index 7b9216e..d9622bc 100644
--- a/docs/html/training/displaying-bitmaps/cache-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
@@ -187,7 +187,7 @@
appropriate place to store cached images if they are accessed more frequently, for example in an
image gallery application.</p>
-<p>The sample code of this class uses a {@code DiskLruCache} implementation that is pulled from the
+<p>The sample code of this class uses a {@code DiskLruCache} implementation that is pulled from the
<a href="https://android.googlesource.com/platform/libcore/+/jb-mr2-release/luni/src/main/java/libcore/io/DiskLruCache.java">Android source</a>.
Here’s updated example code that adds a disk cache in addition to the existing memory cache:</p>
diff --git a/docs/html/training/displaying-bitmaps/index.jd b/docs/html/training/displaying-bitmaps/index.jd
index 831c64d..aea473f 100644
--- a/docs/html/training/displaying-bitmaps/index.jd
+++ b/docs/html/training/displaying-bitmaps/index.jd
@@ -56,7 +56,7 @@
perform under this minimum memory limit. However, keep in mind many devices are configured with
higher limits.</li>
<li>Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the
- camera on the <a href="http://www.android.com/devices/detail/galaxy-nexus">Galaxy Nexus</a> takes
+ camera on the <a href="http://www.android.com/devices/detail/galaxy-nexus">Galaxy Nexus</a> takes
photos up to 2592x1936 pixels (5 megapixels). If the bitmap configuration used is {@link
android.graphics.Bitmap.Config ARGB_8888} (the default from the Android 2.3 onward) then loading
this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the
diff --git a/docs/html/training/displaying-bitmaps/manage-memory.jd b/docs/html/training/displaying-bitmaps/manage-memory.jd
index b7c72bc..ef3bd6c 100644
--- a/docs/html/training/displaying-bitmaps/manage-memory.jd
+++ b/docs/html/training/displaying-bitmaps/manage-memory.jd
@@ -42,11 +42,11 @@
<p>To set the stage for this lesson, here is how Android's management of
bitmap memory has evolved:</p>
-<ul>
+<ul>
<li>
-On Android Android 2.2 (API level 8) and lower, when garbage
+On Android Android 2.2 (API level 8) and lower, when garbage
collection occurs, your app's threads get stopped. This causes a lag that
-can degrade performance.
+can degrade performance.
<strong>Android 2.3 adds concurrent garbage collection, which means that
the memory is reclaimed soon after a bitmap is no longer referenced.</strong>
</li>
@@ -66,7 +66,7 @@
<h2 id="recycle">Manage Memory on Android 2.3.3 and Lower</h2>
-<p>On Android 2.3.3 (API level 10) and lower, using
+<p>On Android 2.3.3 (API level 10) and lower, using
{@link android.graphics.Bitmap#recycle recycle()}
is recommended. If you're displaying large amounts of bitmap data in your app,
you're likely to run into
@@ -82,12 +82,12 @@
<p>The following code snippet gives an example of calling
{@link android.graphics.Bitmap#recycle recycle()}. It uses reference counting
-(in the variables {@code mDisplayRefCount} and {@code mCacheRefCount}) to track
+(in the variables {@code mDisplayRefCount} and {@code mCacheRefCount}) to track
whether a bitmap is currently being displayed or in the cache. The
code recycles the bitmap when these conditions are met:</p>
<ul>
-<li>The reference count for both {@code mDisplayRefCount} and
+<li>The reference count for both {@code mDisplayRefCount} and
{@code mCacheRefCount} is 0.</li>
<li>The bitmap is not {@code null}, and it hasn't been recycled yet.</li>
</ul>
@@ -142,7 +142,7 @@
<p>Android 3.0 (API level 11) introduces the
{@link android.graphics.BitmapFactory.Options#inBitmap BitmapFactory.Options.inBitmap}
-field. If this option is set, decode methods that take the
+field. If this option is set, decode methods that take the
{@link android.graphics.BitmapFactory.Options Options} object
will attempt to reuse an existing bitmap when loading content. This means
that the bitmap's memory is reused, resulting in improved performance, and
@@ -154,7 +154,7 @@
<h3>Save a bitmap for later use</h3>
<p>The following snippet demonstrates how an existing bitmap is stored for possible
-later use in the sample app. When an app is running on Android 3.0 or higher and
+later use in the sample app. When an app is running on Android 3.0 or higher and
a bitmap is evicted from the {@link android.util.LruCache},
a soft reference to the bitmap is placed
in a {@link java.util.HashSet}, for possible reuse later with
@@ -238,7 +238,7 @@
}
}
-// This method iterates through the reusable bitmaps, looking for one
+// This method iterates through the reusable bitmaps, looking for one
// to use for inBitmap:
protected Bitmap getBitmapFromReusableSet(BitmapFactory.Options options) {
Bitmap bitmap = null;
diff --git a/docs/html/training/efficient-downloads/connectivity_patterns.jd b/docs/html/training/efficient-downloads/connectivity_patterns.jd
index 81f1540..079e967 100644
--- a/docs/html/training/efficient-downloads/connectivity_patterns.jd
+++ b/docs/html/training/efficient-downloads/connectivity_patterns.jd
@@ -26,7 +26,7 @@
</div>
<p>When it comes to impact on battery life, not all connection types are created equal. Not only does the Wi-Fi radio use significantly less battery than its wireless radio counterparts, but the radios used in different wireless radio technologies have different battery implications.</p>
-
+
<h2 id="WiFi">Use Wi-Fi</h2>
<p>In most cases a Wi-Fi radio will offer greater bandwidth at a significantly lower battery cost. As a result, you should endeavor to perform data transfers when connected over Wi-Fi whenever possible.</p>
@@ -50,22 +50,22 @@
TelephonyManager tm =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
-
+
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
-
+
int PrefetchCacheSize = DEFAULT_PREFETCH_CACHE;
-
+
switch (activeNetwork.getType()) {
- case (ConnectivityManager.TYPE_WIFI):
+ case (ConnectivityManager.TYPE_WIFI):
PrefetchCacheSize = MAX_PREFETCH_CACHE; break;
case (ConnectivityManager.TYPE_MOBILE): {
switch (tm.getNetworkType()) {
- case (TelephonyManager.NETWORK_TYPE_LTE |
- TelephonyManager.NETWORK_TYPE_HSPAP):
+ case (TelephonyManager.NETWORK_TYPE_LTE |
+ TelephonyManager.NETWORK_TYPE_HSPAP):
PrefetchCacheSize *= 4;
break;
- case (TelephonyManager.NETWORK_TYPE_EDGE |
- TelephonyManager.NETWORK_TYPE_GPRS):
+ case (TelephonyManager.NETWORK_TYPE_EDGE |
+ TelephonyManager.NETWORK_TYPE_GPRS):
PrefetchCacheSize /= 2;
break;
default: break;
diff --git a/docs/html/training/efficient-downloads/efficient-network-access.jd b/docs/html/training/efficient-downloads/efficient-network-access.jd
index 1d3a8a5..7f061ca 100644
--- a/docs/html/training/efficient-downloads/efficient-network-access.jd
+++ b/docs/html/training/efficient-downloads/efficient-network-access.jd
@@ -32,9 +32,9 @@
<p>Using the wireless radio to transfer data is potentially one of your app's most significant sources of battery drain. To minimize the battery drain associated with network activity, it's critical that you understand how your connectivity model will affect the underlying radio hardware.</p>
<p>This lesson introduces the wireless radio state machine and explains how your app's connectivity model interacts with it. It goes on to propose ways to minimize your data connections, use prefetching, and bundle your transfers in order to minimize the battery drain associated with your data transfers.</p>
-
-<h2 id="RadioStateMachine">The Radio State Machine</h2>
-
+
+<h2 id="RadioStateMachine">The Radio State Machine</h2>
+
<p>A fully active wireless radio consumes significant power, so it transitions between different energy states in order to conserve power when not in use, while attempting to minimize latency associated with "powering up" the radio when it's required.</p>
<p>The state machine for a typical 3G network radio consists of three energy states:
@@ -57,9 +57,9 @@
<p>This approach is particularly effective for typical web browsing as it prevents unwelcome latency while users browse the web. The relatively low tail-time also ensures that once a browsing session has finished, the radio can move to a lower energy state.</p>
<p>Unfortunately, this approach can lead to inefficient apps on modern smartphone OSs like Android, where apps run both in the foreground (where latency is important) and in the background (where battery life should be prioritized).</p>
-
-<h2 id="AppsStateMachine">How Apps Impact the Radio State Machine</h2>
-
+
+<h2 id="AppsStateMachine">How Apps Impact the Radio State Machine</h2>
+
<p>Every time you create a new network connection, the radio transitions to the full power state. In the case of the typical 3G radio state machine described above, it will remain at full power for the duration of your transfer—plus an additional 5 seconds of tail time—followed by 12 seconds at the low energy state. So for a typical 3G device, every data transfer session will cause the radio to draw energy for almost 20 seconds.</p>
<p>In practice, this means an app that transfers unbundled data for 1 second every 18 seconds will keep the wireless radio perpetually active, moving it back to high power just as it was about to become idle. As a result, every minute it will consume battery at the high power state for 18 seconds, and at the low power state for the remaining 42 seconds.</p>
@@ -71,7 +71,7 @@
<img src="{@docRoot}images/efficient-downloads/graphs.png" />
<p class="img-caption"><strong>Figure 2.</strong> Relative wireless radio power use for bundled versus unbundled transfers.</p>
-<h2 id="PrefetchData">Prefetch Data</h2>
+<h2 id="PrefetchData">Prefetch Data</h2>
<p>Prefetching data is an effective way to reduce the number of independent data transfer sessions. Prefetching allows you to download all the data you are likely to need for a given time period in a single burst, over a single connection, at full capacity.</p>
@@ -135,7 +135,7 @@
<p>Rather than creating multiple simultaneous connections to download data, or chaining multiple consecutive GET requests, where possible you should bundle those requests into a single GET.</p>
-<p>For example, it would be more efficient to make a single request for every news article to be returned in a single request / response than to make multiple queries for several news categories.
+<p>For example, it would be more efficient to make a single request for every news article to be returned in a single request / response than to make multiple queries for several news categories.
The wireless radio needs to become active in order to transmit the termination / termination acknowledgement packets associated with server and client timeout, so it's also good practice to close your connections when they aren't in use, rather than waiting for these timeouts.</p>
<p>That said, closing a connection too early can prevent it from being reused, which then requires additional overhead for establishing a new connection. A useful compromise is not to close the connection immediately, but to still close it before the inherent timeout expires.</p>
diff --git a/docs/html/training/efficient-downloads/index.jd b/docs/html/training/efficient-downloads/index.jd
index d9d7ef0..a4c2aa1 100644
--- a/docs/html/training/efficient-downloads/index.jd
+++ b/docs/html/training/efficient-downloads/index.jd
@@ -26,18 +26,18 @@
<p>In this class you will learn to minimize the battery life impact of downloads and network connections, particularly in relation to the wireless radio.</P
-<p>This class demonstrates the best practices for scheduling and executing downloads using techniques such as caching, polling, and prefetching. You will learn how the power-use profile of the wireless radio can affect your choices on when, what, and how to transfer data in order to minimize impact on battery life.</p>
+<p>This class demonstrates the best practices for scheduling and executing downloads using techniques such as caching, polling, and prefetching. You will learn how the power-use profile of the wireless radio can affect your choices on when, what, and how to transfer data in order to minimize impact on battery life.</p>
-<h2>Lessons</h2>
-
+<h2>Lessons</h2>
+
<!-- Create a list of the lessons in this class along with a short description of each lesson.
These should be short and to the point. It should be clear from reading the summary whether someone
-will want to jump to a lesson or not.-->
-
-<dl>
+will want to jump to a lesson or not.-->
+
+<dl>
<dt><b><a href="efficient-network-access.html">Optimizing Downloads for Efficient Network Access</a></b></dt>
<dd>This lesson introduces the wireless radio state machine, explains how your app’s connectivity model interacts with it, and how you can minimize your data connection and use prefetching and bundling to minimize the battery drain associated with your data transfers.</dd>
-
+
<dt><b><a href="regular_updates.html">Minimizing the Effect of Regular Updates</a></b></dt>
<dd>This lesson will examine how your refresh frequency can be varied to best mitigate the effect of background updates on the underlying wireless radio state machine.</dd>
@@ -47,4 +47,4 @@
<dt><b><a href="connectivity_patterns.html">Modifying your Download Patterns Based on the Connectivity Type</a></b></dt>
<dd>When it comes to impact on battery life, not all connection types are created equal. Not only does the Wi-Fi radio use significantly less battery than its wireless radio counterparts, but the radios used in different wireless radio technologies have different battery implications.</dd>
-</dl>
+</dl>
diff --git a/docs/html/training/efficient-downloads/regular_updates.jd b/docs/html/training/efficient-downloads/regular_updates.jd
index 8e3842a..b87c512 100644
--- a/docs/html/training/efficient-downloads/regular_updates.jd
+++ b/docs/html/training/efficient-downloads/regular_updates.jd
@@ -33,9 +33,9 @@
<p><a href="{@docRoot}training/monitoring-device-state/index.html">Optimizing Battery Life</a> discusses how to build battery-efficient apps that modify their refresh frequency based on the state of the host device. That includes disabling background service updates when you lose connectivity and reducing the rate of updates when the battery level is low.</p>
<p>This lesson will examine how your refresh frequency can be varied to best mitigate the effect of background updates on the underlying wireless radio state machine.</p>
-
-<h2 id="GCM">Use Google Cloud Messaging as an Alternative to Polling</h2>
-
+
+<h2 id="GCM">Use Google Cloud Messaging as an Alternative to Polling</h2>
+
<p>Every time your app polls your server to check if an update is required, you activate the wireless radio, drawing power unnecessarily, for up to 20 seconds on a typical 3G connection.</p>
<p><a href="{@docRoot}google/gcm/index.html">Google Cloud Messaging for Android (GCM)</a> is a lightweight mechanism used to transmit data from a server to a particular app instance. Using GCM, your server can notify your app running on a particular device that there is new data available for it.</p>
@@ -46,7 +46,7 @@
<p>GCM is implemented using a persistent TCP/IP connection. While it's possible to implement your own push service, it's best practice to use GCM. This minimizes the number of persistent connections and allows the platform to optimize bandwidth and minimize the associated impact on battery life.</p>
-<h2 id="OptimizedPolling">Optimize Polling with Inexact Repeating Alarms and Exponential Backoffs</h2>
+<h2 id="OptimizedPolling">Optimize Polling with Inexact Repeating Alarms and Exponential Backoffs</h2>
<p>Where polling is required, it's good practice to set the default data refresh frequency of your app as low as possible without detracting from the user experience.</p>
@@ -68,14 +68,14 @@
<p>One approach is to implement an exponential back-off pattern to reduce the frequency of your updates (and / or the degree of prefetching you perform) if the app hasn't been used since the previous update. It's often useful to assert a minimum update frequency and to reset the frequency whenever the app is used, for example:</p>
-<pre>SharedPreferences sp =
+<pre>SharedPreferences sp =
context.getSharedPreferences(PREFS, Context.MODE_WORLD_READABLE);
boolean appUsed = sp.getBoolean(PREFS_APPUSED, false);
long updateInterval = sp.getLong(PREFS_INTERVAL, DEFAULT_REFRESH_INTERVAL);
if (!appUsed)
- if ((updateInterval *= 2) > MAX_REFRESH_INTERVAL)
+ if ((updateInterval *= 2) > MAX_REFRESH_INTERVAL)
updateInterval = MAX_REFRESH_INTERVAL;
Editor spEdit = sp.edit();
@@ -92,10 +92,10 @@
<pre>private void retryIn(long interval) {
boolean success = attemptTransfer();
-
+
if (!success) {
- retryIn(interval*2 < MAX_RETRY_INTERVAL ?
- interval*2 : MAX_RETRY_INTERVAL);
+ retryIn(interval*2 < MAX_RETRY_INTERVAL ?
+ interval*2 : MAX_RETRY_INTERVAL);
}
}</pre>
diff --git a/docs/html/training/gestures/detector.jd b/docs/html/training/gestures/detector.jd
index 97f039c..0624e86 100644
--- a/docs/html/training/gestures/detector.jd
+++ b/docs/html/training/gestures/detector.jd
@@ -48,48 +48,48 @@
<ol>
<li>Gathering data about touch events.</li>
-
+
<li>Interpreting the data to see if it meets the criteria for any of the
-gestures your app supports. </li>
+gestures your app supports. </li>
</ol>
<h4>Support Library Classes</h4>
<p>The examples in this lesson use the {@link android.support.v4.view.GestureDetectorCompat}
-and {@link android.support.v4.view.MotionEventCompat} classes. These classes are in the
+and {@link android.support.v4.view.MotionEventCompat} classes. These classes are in the
<a href="{@docRoot}tools/support-library/index.html">Support Library</a>. You should use
-Support Library classes where possible to provide compatibility with devices
-running Android 1.6 and higher. Note that {@link android.support.v4.view.MotionEventCompat} is <em>not</em> a
-replacement for the {@link android.view.MotionEvent} class. Rather, it provides static utility
-methods to which you pass your {@link android.view.MotionEvent} object in order to receive
+Support Library classes where possible to provide compatibility with devices
+running Android 1.6 and higher. Note that {@link android.support.v4.view.MotionEventCompat} is <em>not</em> a
+replacement for the {@link android.view.MotionEvent} class. Rather, it provides static utility
+methods to which you pass your {@link android.view.MotionEvent} object in order to receive
the desired action associated with that event.</p>
<h2 id="data">Gather Data</h2>
<p>When a user places one or more fingers on the screen, this triggers the
-callback {@link android.view.View#onTouchEvent onTouchEvent()}
+callback {@link android.view.View#onTouchEvent onTouchEvent()}
on the View that received the touch events.
-For each sequence of touch events (position, pressure, size, addition of another finger, etc.)
+For each sequence of touch events (position, pressure, size, addition of another finger, etc.)
that is ultimately identified as a gesture,
{@link android.view.View#onTouchEvent onTouchEvent()} is fired several times.</p>
<p>The gesture starts when the user first touches the screen, continues as the system tracks
the position of the user's finger(s), and ends by capturing the final event of
-the user's fingers leaving the screen. Throughout this interaction,
-the {@link android.view.MotionEvent} delivered to {@link android.view.View#onTouchEvent onTouchEvent()}
-provides the details of every interaction. Your app can use the data provided by the {@link android.view.MotionEvent}
+the user's fingers leaving the screen. Throughout this interaction,
+the {@link android.view.MotionEvent} delivered to {@link android.view.View#onTouchEvent onTouchEvent()}
+provides the details of every interaction. Your app can use the data provided by the {@link android.view.MotionEvent}
to determine if a gesture it cares
about happened.</p>
<h3>Capturing touch events for an Activity or View</h3>
-<p><p>To intercept touch events in an Activity or View, override
+<p><p>To intercept touch events in an Activity or View, override
the {@link android.view.View#onTouchEvent onTouchEvent()} callback.</p>
-<p>The following snippet uses
+<p>The following snippet uses
{@link android.support.v4.view.MotionEventCompat#getActionMasked getActionMasked()}
-to extract the action the user performed from the {@code event} parameter. This gives you the raw
+to extract the action the user performed from the {@code event} parameter. This gives you the raw
data you need to determine if a gesture you care about occurred:</p>
<pre>
@@ -98,10 +98,10 @@
// This example shows an Activity, but you would use the same approach if
// you were subclassing a View.
@Override
-public boolean onTouchEvent(MotionEvent event){
-
+public boolean onTouchEvent(MotionEvent event){
+
int action = MotionEventCompat.getActionMasked(event);
-
+
switch(action) {
case (MotionEvent.ACTION_DOWN) :
Log.d(DEBUG_TAG,"Action was DOWN");
@@ -118,10 +118,10 @@
case (MotionEvent.ACTION_OUTSIDE) :
Log.d(DEBUG_TAG,"Movement occurred outside bounds " +
"of current screen element");
- return true;
- default :
+ return true;
+ default :
return super.onTouchEvent(event);
- }
+ }
}</pre>
<p>You can then do your own processing on these events to determine if a
@@ -143,22 +143,22 @@
events without subclassing an existing {@link android.view.View}. For
example:</p>
-<pre>View myView = findViewById(R.id.my_view);
+<pre>View myView = findViewById(R.id.my_view);
myView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
- // ... Respond to touch events
+ // ... Respond to touch events
return true;
}
});</pre>
-<p>Beware of creating a listener that returns {@code false} for the
-{@link android.view.MotionEvent#ACTION_DOWN} event. If you do this, the listener will
-not be called for the subsequent {@link android.view.MotionEvent#ACTION_MOVE}
+<p>Beware of creating a listener that returns {@code false} for the
+{@link android.view.MotionEvent#ACTION_DOWN} event. If you do this, the listener will
+not be called for the subsequent {@link android.view.MotionEvent#ACTION_MOVE}
and {@link android.view.MotionEvent#ACTION_UP} string of events. This is because
{@link android.view.MotionEvent#ACTION_DOWN} is the starting point for all touch events.</p>
-<p>If you are creating a custom View, you can override
-{@link android.view.View#onTouchEvent onTouchEvent()},
+<p>If you are creating a custom View, you can override
+{@link android.view.View#onTouchEvent onTouchEvent()},
as described above.</p>
<h2 id="detect">Detect Gestures</h2>
@@ -168,24 +168,24 @@
android.view.GestureDetector.OnGestureListener#onDown onDown()}, {@link
android.view.GestureDetector.OnGestureListener#onLongPress onLongPress()},
{@link android.view.GestureDetector.OnGestureListener#onFling onFling()}, and so
-on. You can use {@link android.view.GestureDetector} in conjunction with the
+on. You can use {@link android.view.GestureDetector} in conjunction with the
{@link android.view.View#onTouchEvent onTouchEvent()}
method described above.</p>
<h3>Detecting All Supported Gestures</h3>
-<p>When you instantiate a {@link android.support.v4.view.GestureDetectorCompat}
-object, one of the parameters it takes is a class that implements the
-{@link android.view.GestureDetector.OnGestureListener} interface.
-{@link android.view.GestureDetector.OnGestureListener} notifies users when
-a particular touch event has occurred. To make it possible for your
-{@link android.view.GestureDetector} object to receive events, you override
-the View or Activity's {@link android.view.View#onTouchEvent onTouchEvent()} method,
+<p>When you instantiate a {@link android.support.v4.view.GestureDetectorCompat}
+object, one of the parameters it takes is a class that implements the
+{@link android.view.GestureDetector.OnGestureListener} interface.
+{@link android.view.GestureDetector.OnGestureListener} notifies users when
+a particular touch event has occurred. To make it possible for your
+{@link android.view.GestureDetector} object to receive events, you override
+the View or Activity's {@link android.view.View#onTouchEvent onTouchEvent()} method,
and pass along all observed events to the detector instance.</p>
-<p>In the following snippet, a return value of {@code true} from the individual
+<p>In the following snippet, a return value of {@code true} from the individual
<code>on<em><TouchEvent></em></code> methods indicates that you
have handled the touch event. A return value of {@code false} passes events down
through the view stack until the touch has been successfully handled.</p>
@@ -195,14 +195,14 @@
android.view.MotionEvent} are for each touch event. You will realize how much
data is being generated for even simple interactions.</p>
-<pre>public class MainActivity extends Activity implements
+<pre>public class MainActivity extends Activity implements
GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener{
-
- private static final String DEBUG_TAG = "Gestures";
- private GestureDetectorCompat mDetector;
- // Called when the activity is first created.
+ private static final String DEBUG_TAG = "Gestures";
+ private GestureDetectorCompat mDetector;
+
+ // Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -216,21 +216,21 @@
mDetector.setOnDoubleTapListener(this);
}
- @Override
- public boolean onTouchEvent(MotionEvent event){
+ @Override
+ public boolean onTouchEvent(MotionEvent event){
this.mDetector.onTouchEvent(event);
// Be sure to call the superclass implementation
return super.onTouchEvent(event);
}
@Override
- public boolean onDown(MotionEvent event) {
- Log.d(DEBUG_TAG,"onDown: " + event.toString());
+ public boolean onDown(MotionEvent event) {
+ Log.d(DEBUG_TAG,"onDown: " + event.toString());
return true;
}
@Override
- public boolean onFling(MotionEvent event1, MotionEvent event2,
+ public boolean onFling(MotionEvent event1, MotionEvent event2,
float velocityX, float velocityY) {
Log.d(DEBUG_TAG, "onFling: " + event1.toString()+event2.toString());
return true;
@@ -238,7 +238,7 @@
@Override
public void onLongPress(MotionEvent event) {
- Log.d(DEBUG_TAG, "onLongPress: " + event.toString());
+ Log.d(DEBUG_TAG, "onLongPress: " + event.toString());
}
@Override
@@ -294,23 +294,23 @@
android.view.GestureDetector.OnGestureListener#onFling onFling()} and {@link
android.view.GestureDetector.OnGestureListener#onDown onDown()}.</p>
-<p>Whether or not you use {@link android.view.GestureDetector.OnGestureListener},
-it's best practice to implement an
-{@link android.view.GestureDetector.OnGestureListener#onDown onDown()}
-method that returns {@code true}. This is because all gestures begin with an
-{@link android.view.GestureDetector.OnGestureListener#onDown onDown()} message. If you return
-{@code false} from {@link android.view.GestureDetector.OnGestureListener#onDown onDown()},
-as {@link android.view.GestureDetector.SimpleOnGestureListener} does by default,
-the system assumes that you want to ignore the rest of the gesture, and the other methods of
-{@link android.view.GestureDetector.OnGestureListener} never get called.
-This has the potential to cause unexpected problems in your app.
-The only time you should return {@code false} from
-{@link android.view.GestureDetector.OnGestureListener#onDown onDown()}
+<p>Whether or not you use {@link android.view.GestureDetector.OnGestureListener},
+it's best practice to implement an
+{@link android.view.GestureDetector.OnGestureListener#onDown onDown()}
+method that returns {@code true}. This is because all gestures begin with an
+{@link android.view.GestureDetector.OnGestureListener#onDown onDown()} message. If you return
+{@code false} from {@link android.view.GestureDetector.OnGestureListener#onDown onDown()},
+as {@link android.view.GestureDetector.SimpleOnGestureListener} does by default,
+the system assumes that you want to ignore the rest of the gesture, and the other methods of
+{@link android.view.GestureDetector.OnGestureListener} never get called.
+This has the potential to cause unexpected problems in your app.
+The only time you should return {@code false} from
+{@link android.view.GestureDetector.OnGestureListener#onDown onDown()}
is if you truly want to ignore an entire gesture. </p>
-<pre>public class MainActivity extends Activity {
-
- private GestureDetectorCompat mDetector;
+<pre>public class MainActivity extends Activity {
+
+ private GestureDetectorCompat mDetector;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -319,23 +319,23 @@
mDetector = new GestureDetectorCompat(this, new MyGestureListener());
}
- @Override
- public boolean onTouchEvent(MotionEvent event){
+ @Override
+ public boolean onTouchEvent(MotionEvent event){
this.mDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
-
+
class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
- private static final String DEBUG_TAG = "Gestures";
-
+ private static final String DEBUG_TAG = "Gestures";
+
@Override
- public boolean onDown(MotionEvent event) {
- Log.d(DEBUG_TAG,"onDown: " + event.toString());
+ public boolean onDown(MotionEvent event) {
+ Log.d(DEBUG_TAG,"onDown: " + event.toString());
return true;
}
@Override
- public boolean onFling(MotionEvent event1, MotionEvent event2,
+ public boolean onFling(MotionEvent event1, MotionEvent event2,
float velocityX, float velocityY) {
Log.d(DEBUG_TAG, "onFling: " + event1.toString()+event2.toString());
return true;
diff --git a/docs/html/training/gestures/index.jd b/docs/html/training/gestures/index.jd
index 260cfff..fad1afa 100644
--- a/docs/html/training/gestures/index.jd
+++ b/docs/html/training/gestures/index.jd
@@ -60,7 +60,7 @@
<strong><a href="detector.html">Detecting Common Gestures</a></strong>
</dt>
<dd>
- Learn how to detect basic touch gestures such as scrolling, flinging, and double-tapping, using
+ Learn how to detect basic touch gestures such as scrolling, flinging, and double-tapping, using
{@link android.view.GestureDetector}.
</dd>
@@ -84,7 +84,7 @@
</dt>
<dd>
Learn how to detect multi-pointer (finger) gestures.
- </dd>
+ </dd>
<dt>
<strong><a href="scale.html">Dragging and Scaling</a></strong>
</dt>
diff --git a/docs/html/training/gestures/movement.jd b/docs/html/training/gestures/movement.jd
index ed4928e..0a611b3 100644
--- a/docs/html/training/gestures/movement.jd
+++ b/docs/html/training/gestures/movement.jd
@@ -55,13 +55,13 @@
To help apps distinguish between movement-based gestures (such as a swipe) and
non-movement gestures (such as a single tap), Android includes the notion of
"touch slop." Touch slop refers to the distance in pixels a user's touch can wander
-before the gesture is interpreted as a movement-based gesture. For more discussion of this
+before the gesture is interpreted as a movement-based gesture. For more discussion of this
topic, see <a href="viewgroup.html#vc">Managing Touch Events in a ViewGroup</a>.</p>
<p>There are several different ways to track movement in a gesture, depending on
-the needs of your application. For example:</p>
+the needs of your application. For example:</p>
<ul>
@@ -89,8 +89,8 @@
<p> You could have a movement-based gesture that is simply based on the distance and/or direction the pointer traveled. But velocity often is a
determining factor in tracking a gesture's characteristics or even deciding
whether the gesture occurred. To make velocity calculation easier, Android
-provides the {@link android.view.VelocityTracker} class and the
-{@link android.support.v4.view.VelocityTrackerCompat} class in the
+provides the {@link android.view.VelocityTracker} class and the
+{@link android.support.v4.view.VelocityTrackerCompat} class in the
<a href="{@docRoot}tools/support-library/index.html">Support Library</a>.
{@link
android.view.VelocityTracker} helps you track the velocity of touch events. This
@@ -98,7 +98,7 @@
gesture, such as a fling.</p>
-<p>Here is a simple example that illustrates the purpose of the methods in the
+<p>Here is a simple example that illustrates the purpose of the methods in the
{@link android.view.VelocityTracker} API:</p>
<pre>public class MainActivity extends Activity {
@@ -126,16 +126,16 @@
break;
case MotionEvent.ACTION_MOVE:
mVelocityTracker.addMovement(event);
- // When you want to determine the velocity, call
- // computeCurrentVelocity(). Then call getXVelocity()
- // and getYVelocity() to retrieve the velocity for each pointer ID.
+ // When you want to determine the velocity, call
+ // computeCurrentVelocity(). Then call getXVelocity()
+ // and getYVelocity() to retrieve the velocity for each pointer ID.
mVelocityTracker.computeCurrentVelocity(1000);
// Log velocity of pixels per second
// Best practice to use VelocityTrackerCompat where possible.
- Log.d("", "X velocity: " +
- VelocityTrackerCompat.getXVelocity(mVelocityTracker,
+ Log.d("", "X velocity: " +
+ VelocityTrackerCompat.getXVelocity(mVelocityTracker,
pointerId));
- Log.d("", "Y velocity: " +
+ Log.d("", "Y velocity: " +
VelocityTrackerCompat.getYVelocity(mVelocityTracker,
pointerId));
break;
@@ -150,8 +150,8 @@
}
</pre>
-<p class="note"><strong>Note:</strong> Note that you should calculate velocity after an
-{@link android.view.MotionEvent#ACTION_MOVE} event,
-not after {@link android.view.MotionEvent#ACTION_UP}. After an {@link android.view.MotionEvent#ACTION_UP},
+<p class="note"><strong>Note:</strong> Note that you should calculate velocity after an
+{@link android.view.MotionEvent#ACTION_MOVE} event,
+not after {@link android.view.MotionEvent#ACTION_UP}. After an {@link android.view.MotionEvent#ACTION_UP},
the X and Y velocities will be 0.
</p>
diff --git a/docs/html/training/gestures/multi.jd b/docs/html/training/gestures/multi.jd
index 5840482..21860fc 100644
--- a/docs/html/training/gestures/multi.jd
+++ b/docs/html/training/gestures/multi.jd
@@ -47,15 +47,15 @@
<h2 id="track">Track Multiple Pointers</h2>
-<p>When multiple pointers touch the screen at the same time, the system generates the
+<p>When multiple pointers touch the screen at the same time, the system generates the
following touch events:</p>
<ul>
- <li>{@link android.view.MotionEvent#ACTION_DOWN}—For the first pointer that
-touches the screen. This starts the gesture. The pointer data for this pointer is
+ <li>{@link android.view.MotionEvent#ACTION_DOWN}—For the first pointer that
+touches the screen. This starts the gesture. The pointer data for this pointer is
always at index 0 in the {@link android.view.MotionEvent}.</li>
- <li>{@link android.support.v4.view.MotionEventCompat#ACTION_POINTER_DOWN}—For
-extra pointers that enter the screen beyond the first. The pointer data for this
+ <li>{@link android.support.v4.view.MotionEventCompat#ACTION_POINTER_DOWN}—For
+extra pointers that enter the screen beyond the first. The pointer data for this
pointer is at the index returned by {@link android.support.v4.view.MotionEventCompat#getActionIndex getActionIndex()}.</li>
<li>{@link android.view.MotionEvent#ACTION_MOVE}—A change has happened during a press gesture.</li>
<li>{@link android.support.v4.view.MotionEventCompat#ACTION_POINTER_UP}—Sent when a non-primary pointer goes up.</li>
@@ -66,20 +66,20 @@
android.view.MotionEvent} via each pointer's index and ID:</p>
<ul>
-<li><strong>Index</strong>: A {@link android.view.MotionEvent} effectively
-stores information about each pointer in an array. The index of a pointer is its position
+<li><strong>Index</strong>: A {@link android.view.MotionEvent} effectively
+stores information about each pointer in an array. The index of a pointer is its position
within this array. Most of the {@link
android.view.MotionEvent} methods you use to interact with pointers take the
pointer index as a parameter, not the pointer ID. </li>
-
-
+
+
<li><strong>ID</strong>: Each pointer also has an ID mapping that stays
-persistent across touch events to allow tracking an individual pointer across
+persistent across touch events to allow tracking an individual pointer across
the entire gesture.</li>
-
+
</ul>
-<p>The order in which individual pointers appear within a motion event is
+<p>The order in which individual pointers appear within a motion event is
undefined. Thus the index of a pointer can change from one event to the
next, but the pointer ID of a pointer is guaranteed to remain constant as long
as the pointer remains active. Use the {@link
@@ -91,7 +91,7 @@
<pre>private int mActivePointerId;
-
+
public boolean onTouchEvent(MotionEvent event) {
....
// Get the pointer ID
@@ -99,7 +99,7 @@
// ... Many touch events later...
- // Use the pointer ID to find the index of the active pointer
+ // Use the pointer ID to find the index of the active pointer
// and fetch its position
int pointerIndex = event.findPointerIndex(mActivePointerId);
// Get the pointer's current position
@@ -109,25 +109,25 @@
<h2 id="action">Get a MotionEvent's Action</h2>
-<p>You should always use the method
-{@link android.view.MotionEvent#getActionMasked getActionMasked()} (or better yet, the compatability version
-{@link android.support.v4.view.MotionEventCompat#getActionMasked MotionEventCompat.getActionMasked()}) to retrieve
+<p>You should always use the method
+{@link android.view.MotionEvent#getActionMasked getActionMasked()} (or better yet, the compatability version
+{@link android.support.v4.view.MotionEventCompat#getActionMasked MotionEventCompat.getActionMasked()}) to retrieve
the action of a
-{@link android.view.MotionEvent}. Unlike the older {@link android.view.MotionEvent#getAction getAction()}
-method, {@link android.support.v4.view.MotionEventCompat#getActionMasked getActionMasked()} is designed to work with
-multiple pointers. It returns the masked action
-being performed, without including the pointer index bits. You can then use
-{@link android.support.v4.view.MotionEventCompat#getActionIndex getActionIndex()} to return the index of
+{@link android.view.MotionEvent}. Unlike the older {@link android.view.MotionEvent#getAction getAction()}
+method, {@link android.support.v4.view.MotionEventCompat#getActionMasked getActionMasked()} is designed to work with
+multiple pointers. It returns the masked action
+being performed, without including the pointer index bits. You can then use
+{@link android.support.v4.view.MotionEventCompat#getActionIndex getActionIndex()} to return the index of
the pointer associated with the action. This is illustrated in the snippet below.</p>
-<p class="note"><strong>Note:</strong> This example uses the
+<p class="note"><strong>Note:</strong> This example uses the
{@link android.support.v4.view.MotionEventCompat}
-class. This class is in the
+class. This class is in the
<a href="{@docRoot}tools/support-library/index.html">Support Library</a>. You should use
{@link android.support.v4.view.MotionEventCompat} to provide the best support for a wide range of
-platforms. Note that {@link android.support.v4.view.MotionEventCompat} is <em>not</em> a
-replacement for the {@link android.view.MotionEvent} class. Rather, it provides static utility
-methods to which you pass your {@link android.view.MotionEvent} object in order to receive
+platforms. Note that {@link android.support.v4.view.MotionEventCompat} is <em>not</em> a
+replacement for the {@link android.view.MotionEvent} class. Rather, it provides static utility
+methods to which you pass your {@link android.view.MotionEvent} object in order to receive
the desired action associated with that event.</p>
<pre>int action = MotionEventCompat.getActionMasked(event);
@@ -137,17 +137,17 @@
int yPos = -1;
Log.d(DEBUG_TAG,"The action is " + actionToString(action));
-
+
if (event.getPointerCount() > 1) {
- Log.d(DEBUG_TAG,"Multitouch event");
- // The coordinates of the current screen contact, relative to
- // the responding View or Activity.
+ Log.d(DEBUG_TAG,"Multitouch event");
+ // The coordinates of the current screen contact, relative to
+ // the responding View or Activity.
xPos = (int)MotionEventCompat.getX(event, index);
yPos = (int)MotionEventCompat.getY(event, index);
} else {
// Single touch event
- Log.d(DEBUG_TAG,"Single touch event");
+ Log.d(DEBUG_TAG,"Single touch event");
xPos = (int)MotionEventCompat.getX(event, index);
yPos = (int)MotionEventCompat.getY(event, index);
}
@@ -156,7 +156,7 @@
// Given an action int, returns a string description
public static String actionToString(int action) {
switch (action) {
-
+
case MotionEvent.ACTION_DOWN: return "Down";
case MotionEvent.ACTION_MOVE: return "Move";
case MotionEvent.ACTION_POINTER_DOWN: return "Pointer Down";
@@ -168,7 +168,7 @@
return "";
}</pre>
-
+
<p>For more discussion of multi-touch and some examples, see the lesson <a href="scale.html">Dragging and Scaling</a>.
diff --git a/docs/html/training/gestures/scale.jd b/docs/html/training/gestures/scale.jd
index f2e4eb8..d4aa916 100644
--- a/docs/html/training/gestures/scale.jd
+++ b/docs/html/training/gestures/scale.jd
@@ -44,13 +44,13 @@
<p>This lesson describes how to use touch gestures to drag and scale on-screen
objects, using {@link android.view.View#onTouchEvent onTouchEvent()} to intercept
-touch events.
+touch events.
</p>
<h2 id="drag">Drag an Object</h2>
-<p class="note">If you are targeting Android 3.0 or higher, you can use the built-in drag-and-drop event
-listeners with {@link android.view.View.OnDragListener}, as described in
+<p class="note">If you are targeting Android 3.0 or higher, you can use the built-in drag-and-drop event
+listeners with {@link android.view.View.OnDragListener}, as described in
<a href="{@docRoot}guide/topics/ui/drag-drop.html">Drag and Drop</a>.
<p>A common operation for a touch gesture is to use it to drag an object across
@@ -66,14 +66,14 @@
individual pointers, it will regard the second pointer as the default and move
the image to that location.</li>
-<li>To prevent this from happening, your app needs to distinguish between the
-original pointer and any follow-on pointers. To do this, it tracks the
-{@link android.view.MotionEvent#ACTION_POINTER_DOWN} and
-{@link android.view.MotionEvent#ACTION_POINTER_UP} events described in
-<a href="multi.html">Handling Multi-Touch Gestures</a>.
-{@link android.view.MotionEvent#ACTION_POINTER_DOWN} and
-{@link android.view.MotionEvent#ACTION_POINTER_UP} are
-passed to the {@link android.view.View#onTouchEvent onTouchEvent()} callback
+<li>To prevent this from happening, your app needs to distinguish between the
+original pointer and any follow-on pointers. To do this, it tracks the
+{@link android.view.MotionEvent#ACTION_POINTER_DOWN} and
+{@link android.view.MotionEvent#ACTION_POINTER_UP} events described in
+<a href="multi.html">Handling Multi-Touch Gestures</a>.
+{@link android.view.MotionEvent#ACTION_POINTER_DOWN} and
+{@link android.view.MotionEvent#ACTION_POINTER_UP} are
+passed to the {@link android.view.View#onTouchEvent onTouchEvent()} callback
whenever a secondary pointer goes down or up. </li>
@@ -90,16 +90,16 @@
<p>The following snippet enables a user to drag an object around on the screen. It records the initial
position of the active pointer, calculates the distance the pointer traveled, and moves the object to the
new position. It correctly manages the possibility of additional pointers, as described
-above.</p>
+above.</p>
-<p>Notice that the snippet uses the {@link android.view.MotionEvent#getActionMasked getActionMasked()} method.
-You should always use this method (or better yet, the compatability version
-{@link android.support.v4.view.MotionEventCompat#getActionMasked MotionEventCompat.getActionMasked()})
+<p>Notice that the snippet uses the {@link android.view.MotionEvent#getActionMasked getActionMasked()} method.
+You should always use this method (or better yet, the compatability version
+{@link android.support.v4.view.MotionEventCompat#getActionMasked MotionEventCompat.getActionMasked()})
to retrieve the action of a
-{@link android.view.MotionEvent}. Unlike the older
-{@link android.view.MotionEvent#getAction getAction()}
-method, {@link android.support.v4.view.MotionEventCompat#getActionMasked getActionMasked()}
-is designed to work with multiple pointers. It returns the masked action
+{@link android.view.MotionEvent}. Unlike the older
+{@link android.view.MotionEvent#getAction getAction()}
+method, {@link android.support.v4.view.MotionEventCompat#getActionMasked getActionMasked()}
+is designed to work with multiple pointers. It returns the masked action
being performed, without including the pointer index bits.</p>
<pre>// The ‘active pointer’ is the one currently moving our object.
@@ -109,15 +109,15 @@
public boolean onTouchEvent(MotionEvent ev) {
// Let the ScaleGestureDetector inspect all events.
mScaleDetector.onTouchEvent(ev);
-
- final int action = MotionEventCompat.getActionMasked(ev);
-
- switch (action) {
+
+ final int action = MotionEventCompat.getActionMasked(ev);
+
+ switch (action) {
case MotionEvent.ACTION_DOWN: {
- final int pointerIndex = MotionEventCompat.getActionIndex(ev);
- final float x = MotionEventCompat.getX(ev, pointerIndex);
- final float y = MotionEventCompat.getY(ev, pointerIndex);
-
+ final int pointerIndex = MotionEventCompat.getActionIndex(ev);
+ final float x = MotionEventCompat.getX(ev, pointerIndex);
+ final float y = MotionEventCompat.getY(ev, pointerIndex);
+
// Remember where we started (for dragging)
mLastTouchX = x;
mLastTouchY = y;
@@ -125,15 +125,15 @@
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
break;
}
-
+
case MotionEvent.ACTION_MOVE: {
// Find the index of the active pointer and fetch its position
- final int pointerIndex =
- MotionEventCompat.findPointerIndex(ev, mActivePointerId);
-
+ final int pointerIndex =
+ MotionEventCompat.findPointerIndex(ev, mActivePointerId);
+
final float x = MotionEventCompat.getX(ev, pointerIndex);
final float y = MotionEventCompat.getY(ev, pointerIndex);
-
+
// Calculate the distance moved
final float dx = x - mLastTouchX;
final float dy = y - mLastTouchY;
@@ -149,62 +149,62 @@
break;
}
-
+
case MotionEvent.ACTION_UP: {
mActivePointerId = INVALID_POINTER_ID;
break;
}
-
+
case MotionEvent.ACTION_CANCEL: {
mActivePointerId = INVALID_POINTER_ID;
break;
}
-
+
case MotionEvent.ACTION_POINTER_UP: {
-
- final int pointerIndex = MotionEventCompat.getActionIndex(ev);
- final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
+
+ final int pointerIndex = MotionEventCompat.getActionIndex(ev);
+ final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- mLastTouchX = MotionEventCompat.getX(ev, newPointerIndex);
- mLastTouchY = MotionEventCompat.getY(ev, newPointerIndex);
+ mLastTouchX = MotionEventCompat.getX(ev, newPointerIndex);
+ mLastTouchY = MotionEventCompat.getY(ev, newPointerIndex);
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
}
break;
}
- }
+ }
return true;
}</pre>
<h2 id="pan">Drag to Pan</h2>
-<p>The previous section showed an example of dragging an object around the screen. Another
-common scenario is <em>panning</em>, which is when a user's dragging motion causes scrolling
-in both the x and y axes. The above snippet directly intercepted the {@link android.view.MotionEvent}
-actions to implement dragging. The snippet in this section takes advantage of the platform's
-built-in support for common gestures. It overrides
-{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} in
+<p>The previous section showed an example of dragging an object around the screen. Another
+common scenario is <em>panning</em>, which is when a user's dragging motion causes scrolling
+in both the x and y axes. The above snippet directly intercepted the {@link android.view.MotionEvent}
+actions to implement dragging. The snippet in this section takes advantage of the platform's
+built-in support for common gestures. It overrides
+{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} in
{@link android.view.GestureDetector.SimpleOnGestureListener}.</p>
-<p>To provide a little more context, {@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()}
-is called when a user is dragging his finger to pan the content.
-{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} is only called when
-a finger is down; as soon as the finger is lifted from the screen, the gesture either ends,
-or a fling gesture is started (if the finger was moving with some speed just before it was lifted).
+<p>To provide a little more context, {@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()}
+is called when a user is dragging his finger to pan the content.
+{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} is only called when
+a finger is down; as soon as the finger is lifted from the screen, the gesture either ends,
+or a fling gesture is started (if the finger was moving with some speed just before it was lifted).
For more discussion of scrolling vs. flinging, see <a href="scroll.html">Animating a Scroll Gesture</a>.</p>
<p>Here is the snippet for {@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()}:
-<pre>// The current viewport. This rectangle represents the currently visible
-// chart domain and range.
-private RectF mCurrentViewport =
+<pre>// The current viewport. This rectangle represents the currently visible
+// chart domain and range.
+private RectF mCurrentViewport =
new RectF(AXIS_X_MIN, AXIS_Y_MIN, AXIS_X_MAX, AXIS_Y_MAX);
-// The current destination rectangle (in pixel coordinates) into which the
+// The current destination rectangle (in pixel coordinates) into which the
// chart data should be drawn.
private Rect mContentRect;
@@ -213,18 +213,18 @@
...
@Override
-public boolean onScroll(MotionEvent e1, MotionEvent e2,
+public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
// Scrolling uses math based on the viewport (as opposed to math using pixels).
-
+
// Pixel offset is the offset in screen pixels, while viewport offset is the
- // offset within the current viewport.
- float viewportOffsetX = distanceX * mCurrentViewport.width()
+ // offset within the current viewport.
+ float viewportOffsetX = distanceX * mCurrentViewport.width()
/ mContentRect.width();
- float viewportOffsetY = -distanceY * mCurrentViewport.height()
+ float viewportOffsetY = -distanceY * mCurrentViewport.height()
/ mContentRect.height();
...
- // Updates the viewport, refreshes the display.
+ // Updates the viewport, refreshes the display.
setViewportBottomLeft(
mCurrentViewport.left + viewportOffsetX,
mCurrentViewport.bottom + viewportOffsetY);
@@ -232,20 +232,20 @@
return true;
}</pre>
-<p>The implementation of {@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()}
+<p>The implementation of {@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()}
scrolls the viewport in response to the touch gesture:</p>
<pre>
/**
* Sets the current viewport (defined by mCurrentViewport) to the given
- * X and Y positions. Note that the Y value represents the topmost pixel position,
+ * X and Y positions. Note that the Y value represents the topmost pixel position,
* and thus the bottom of the mCurrentViewport rectangle.
*/
private void setViewportBottomLeft(float x, float y) {
/*
- * Constrains within the scroll range. The scroll range is simply the viewport
- * extremes (AXIS_X_MAX, etc.) minus the viewport size. For example, if the
- * extremes were 0 and 10, and the viewport size was 2, the scroll range would
+ * Constrains within the scroll range. The scroll range is simply the viewport
+ * extremes (AXIS_X_MAX, etc.) minus the viewport size. For example, if the
+ * extremes were 0 and 10, and the viewport size was 2, the scroll range would
* be 0 to 8.
*/
@@ -270,11 +270,11 @@
android.view.GestureDetector} and {@link android.view.ScaleGestureDetector} can
be used together when you want a view to recognize additional gestures.</p>
-<p>To report detected gesture events, gesture detectors use listener objects
-passed to their constructors. {@link android.view.ScaleGestureDetector} uses
-{@link android.view.ScaleGestureDetector.OnScaleGestureListener}.
-Android provides
-{@link android.view.ScaleGestureDetector.SimpleOnScaleGestureListener}
+<p>To report detected gesture events, gesture detectors use listener objects
+passed to their constructors. {@link android.view.ScaleGestureDetector} uses
+{@link android.view.ScaleGestureDetector.OnScaleGestureListener}.
+Android provides
+{@link android.view.ScaleGestureDetector.SimpleOnScaleGestureListener}
as a helper class that you can extend if you don’t care about all of the reported events.</p>
@@ -311,7 +311,7 @@
canvas.restore();
}
-private class ScaleListener
+private class ScaleListener
extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
@@ -329,14 +329,14 @@
<h3>More complex scaling example</h3>
-<p>Here is a more complex example from the {@code InteractiveChart} sample provided with this class.
+<p>Here is a more complex example from the {@code InteractiveChart} sample provided with this class.
The {@code InteractiveChart} sample supports both scrolling (panning) and scaling with multiple fingers,
-using the {@link android.view.ScaleGestureDetector} "span"
-({@link android.view.ScaleGestureDetector#getCurrentSpanX getCurrentSpanX/Y}) and
+using the {@link android.view.ScaleGestureDetector} "span"
+({@link android.view.ScaleGestureDetector#getCurrentSpanX getCurrentSpanX/Y}) and
"focus" ({@link android.view.ScaleGestureDetector#getFocusX getFocusX/Y}) features:</p>
<pre>@Override
-private RectF mCurrentViewport =
+private RectF mCurrentViewport =
new RectF(AXIS_X_MIN, AXIS_Y_MIN, AXIS_X_MAX, AXIS_Y_MAX);
private Rect mContentRect;
private ScaleGestureDetector mScaleGestureDetector;
@@ -399,7 +399,7 @@
0,
0);
mCurrentViewport.right = mCurrentViewport.left + newWidth;
- mCurrentViewport.bottom = mCurrentViewport.top + newHeight;
+ mCurrentViewport.bottom = mCurrentViewport.top + newHeight;
...
// Invalidates the View to update the display.
ViewCompat.postInvalidateOnAnimation(InteractiveLineGraphView.this);
diff --git a/docs/html/training/gestures/scroll.jd b/docs/html/training/gestures/scroll.jd
index 4b82d69..374ceff 100644
--- a/docs/html/training/gestures/scroll.jd
+++ b/docs/html/training/gestures/scroll.jd
@@ -41,12 +41,12 @@
</div>
</div>
-<p>In Android, scrolling is typically achieved by using the
+<p>In Android, scrolling is typically achieved by using the
{@link android.widget.ScrollView}
-class. Any standard layout that might extend beyond the bounds of its container should be
-nested in a {@link android.widget.ScrollView} to provide a scrollable view that's
-managed by the framework. Implementing a custom scroller should only be
-necessary for special scenarios. This lesson describes such a scenario: displaying
+class. Any standard layout that might extend beyond the bounds of its container should be
+nested in a {@link android.widget.ScrollView} to provide a scrollable view that's
+managed by the framework. Implementing a custom scroller should only be
+necessary for special scenarios. This lesson describes such a scenario: displaying
a scrolling effect in response to touch gestures using <em>scrollers</em>.
@@ -54,8 +54,8 @@
android.widget.OverScroller}) to collect the data you need to produce a
scrolling animation in response to a touch event. They are similar, but
{@link android.widget.OverScroller}
-includes methods for indicating to users that they've reached the content edges
-after a pan or fling gesture. The {@code InteractiveChart} sample
+includes methods for indicating to users that they've reached the content edges
+after a pan or fling gesture. The {@code InteractiveChart} sample
uses the {@link android.widget.EdgeEffect} class
(actually the {@link android.support.v4.widget.EdgeEffectCompat} class)
to display a "glow" effect when users reach the content edges.</p>
@@ -68,7 +68,7 @@
<br />
Also note that you generally only need to use scrollers
when implementing scrolling yourself. {@link android.widget.ScrollView} and
-{@link android.widget.HorizontalScrollView} do all of this for you if you nest your
+{@link android.widget.HorizontalScrollView} do all of this for you if you nest your
layout within them.
</p>
@@ -86,71 +86,71 @@
<p>"Scrolling" is a word that can take on different meanings in Android, depending on the context.</p>
-<p><strong>Scrolling</strong> is the general process of moving the viewport (that is, the 'window'
-of content you're looking at). When scrolling is in both the x and y axes, it's called
-<em>panning</em>. The sample application provided with this class, {@code InteractiveChart}, illustrates
+<p><strong>Scrolling</strong> is the general process of moving the viewport (that is, the 'window'
+of content you're looking at). When scrolling is in both the x and y axes, it's called
+<em>panning</em>. The sample application provided with this class, {@code InteractiveChart}, illustrates
two different types of scrolling, dragging and flinging:</p>
<ul>
- <li><strong>Dragging</strong> is the type of scrolling that occurs when a user drags her
-finger across the touch screen. Simple dragging is often implemented by overriding
-{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} in
-{@link android.view.GestureDetector.OnGestureListener}. For more discussion of dragging, see
+ <li><strong>Dragging</strong> is the type of scrolling that occurs when a user drags her
+finger across the touch screen. Simple dragging is often implemented by overriding
+{@link android.view.GestureDetector.OnGestureListener#onScroll onScroll()} in
+{@link android.view.GestureDetector.OnGestureListener}. For more discussion of dragging, see
<a href="scale.html">Dragging and Scaling</a>.</li>
- <li><strong>Flinging</strong> is the type of scrolling that occurs when a user
-drags and lifts her finger quickly. After the user lifts her finger, you generally
-want to keep scrolling (moving the viewport), but decelerate until the viewport stops moving.
-Flinging can be implemented by overriding
-{@link android.view.GestureDetector.OnGestureListener#onFling onFling()}
-in {@link android.view.GestureDetector.OnGestureListener}, and by using
-a scroller object. This is the use
+ <li><strong>Flinging</strong> is the type of scrolling that occurs when a user
+drags and lifts her finger quickly. After the user lifts her finger, you generally
+want to keep scrolling (moving the viewport), but decelerate until the viewport stops moving.
+Flinging can be implemented by overriding
+{@link android.view.GestureDetector.OnGestureListener#onFling onFling()}
+in {@link android.view.GestureDetector.OnGestureListener}, and by using
+a scroller object. This is the use
case that is the topic of this lesson.</li>
</ul>
-<p>It's common to use scroller objects
+<p>It's common to use scroller objects
in conjunction with a fling gesture, but they
can be used in pretty much any context where you want the UI to display
-scrolling in response to a touch event. For example, you could override
-{@link android.view.View#onTouchEvent onTouchEvent()} to process touch
-events directly, and produce a scrolling effect or a "snapping to page" animation
+scrolling in response to a touch event. For example, you could override
+{@link android.view.View#onTouchEvent onTouchEvent()} to process touch
+events directly, and produce a scrolling effect or a "snapping to page" animation
in response to those touch events.</p>
-<h2 id="#scroll">Implement Touch-Based Scrolling</h2>
+<h2 id="#scroll">Implement Touch-Based Scrolling</h2>
<p>This section describes how to use a scroller.
-The snippet shown below comes from the {@code InteractiveChart} sample
+The snippet shown below comes from the {@code InteractiveChart} sample
provided with this class.
-It uses a
-{@link android.view.GestureDetector}, and overrides the
-{@link android.view.GestureDetector.SimpleOnGestureListener} method
+It uses a
+{@link android.view.GestureDetector}, and overrides the
+{@link android.view.GestureDetector.SimpleOnGestureListener} method
{@link android.view.GestureDetector.OnGestureListener#onFling onFling()}.
It uses {@link android.widget.OverScroller} to track the fling gesture.
-If the user reaches the content edges
+If the user reaches the content edges
after the fling gesture, the app displays a "glow" effect.
</p>
-<p class="note"><strong>Note:</strong> The {@code InteractiveChart} sample app displays a
-chart that you can zoom, pan, scroll, and so on. In the following snippet,
-{@code mContentRect} represents the rectangle coordinates within the view that the chart
-will be drawn into. At any given time, a subset of the total chart domain and range are drawn
-into this rectangular area.
-{@code mCurrentViewport} represents the portion of the chart that is currently
-visible in the screen. Because pixel offsets are generally treated as integers,
-{@code mContentRect} is of the type {@link android.graphics.Rect}. Because the
-graph domain and range are decimal/float values, {@code mCurrentViewport} is of
+<p class="note"><strong>Note:</strong> The {@code InteractiveChart} sample app displays a
+chart that you can zoom, pan, scroll, and so on. In the following snippet,
+{@code mContentRect} represents the rectangle coordinates within the view that the chart
+will be drawn into. At any given time, a subset of the total chart domain and range are drawn
+into this rectangular area.
+{@code mCurrentViewport} represents the portion of the chart that is currently
+visible in the screen. Because pixel offsets are generally treated as integers,
+{@code mContentRect} is of the type {@link android.graphics.Rect}. Because the
+graph domain and range are decimal/float values, {@code mCurrentViewport} is of
the type {@link android.graphics.RectF}.</p>
-<p>The first part of the snippet shows the implementation of
+<p>The first part of the snippet shows the implementation of
{@link android.view.GestureDetector.OnGestureListener#onFling onFling()}:</p>
-<pre>// The current viewport. This rectangle represents the currently visible
+<pre>// The current viewport. This rectangle represents the currently visible
// chart domain and range. The viewport is the part of the app that the
// user manipulates via touch gestures.
-private RectF mCurrentViewport =
+private RectF mCurrentViewport =
new RectF(AXIS_X_MIN, AXIS_Y_MIN, AXIS_X_MAX, AXIS_Y_MAX);
-// The current destination rectangle (in pixel coordinates) into which the
+// The current destination rectangle (in pixel coordinates) into which the
// chart data should be drawn.
private Rect mContentRect;
@@ -171,7 +171,7 @@
}
...
@Override
- public boolean onFling(MotionEvent e1, MotionEvent e2,
+ public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
fling((int) -velocityX, (int) -velocityY);
return true;
@@ -184,10 +184,10 @@
// Flings use math in pixels (as opposed to math based on the viewport).
Point surfaceSize = computeScrollSurfaceSize();
mScrollerStartViewport.set(mCurrentViewport);
- int startX = (int) (surfaceSize.x * (mScrollerStartViewport.left -
+ int startX = (int) (surfaceSize.x * (mScrollerStartViewport.left -
AXIS_X_MIN) / (
AXIS_X_MAX - AXIS_X_MIN));
- int startY = (int) (surfaceSize.y * (AXIS_Y_MAX -
+ int startY = (int) (surfaceSize.y * (AXIS_Y_MAX -
mScrollerStartViewport.bottom) / (
AXIS_Y_MAX - AXIS_Y_MIN));
// Before flinging, aborts the current animation.
@@ -200,10 +200,10 @@
velocityX,
velocityY,
/*
- * Minimum and maximum scroll positions. The minimum scroll
- * position is generally zero and the maximum scroll position
- * is generally the content size less the screen size. So if the
- * content width is 1000 pixels and the screen width is 200
+ * Minimum and maximum scroll positions. The minimum scroll
+ * position is generally zero and the maximum scroll position
+ * is generally the content size less the screen size. So if the
+ * content width is 1000 pixels and the screen width is 200
* pixels, the maximum scroll offset should be 800 pixels.
*/
0, surfaceSize.x - mContentRect.width(),
@@ -216,21 +216,21 @@
ViewCompat.postInvalidateOnAnimation(this);
}</pre>
-<p>When {@link android.view.GestureDetector.OnGestureListener#onFling onFling()} calls
-{@link android.support.v4.view.ViewCompat#postInvalidateOnAnimation postInvalidateOnAnimation()},
-it triggers
-{@link android.view.View#computeScroll computeScroll()} to update the values for x and y.
+<p>When {@link android.view.GestureDetector.OnGestureListener#onFling onFling()} calls
+{@link android.support.v4.view.ViewCompat#postInvalidateOnAnimation postInvalidateOnAnimation()},
+it triggers
+{@link android.view.View#computeScroll computeScroll()} to update the values for x and y.
This is typically be done when a view child is animating a scroll using a scroller object, as in this example. </p>
-<p>Most views pass the scroller object's x and y position directly to
-{@link android.view.View#scrollTo scrollTo()}.
-The following implementation of {@link android.view.View#computeScroll computeScroll()}
-takes a different approach—it calls
-{@link android.widget.OverScroller#computeScrollOffset computeScrollOffset()} to get the current
-location of x and y. When the criteria for displaying an overscroll "glow" edge effect are met
-(the display is zoomed in, x or y is out of bounds, and the app isn't already showing an overscroll),
-the code sets up the overscroll glow effect and calls
-{@link android.support.v4.view.ViewCompat#postInvalidateOnAnimation postInvalidateOnAnimation()}
+<p>Most views pass the scroller object's x and y position directly to
+{@link android.view.View#scrollTo scrollTo()}.
+The following implementation of {@link android.view.View#computeScroll computeScroll()}
+takes a different approach—it calls
+{@link android.widget.OverScroller#computeScrollOffset computeScrollOffset()} to get the current
+location of x and y. When the criteria for displaying an overscroll "glow" edge effect are met
+(the display is zoomed in, x or y is out of bounds, and the app isn't already showing an overscroll),
+the code sets up the overscroll glow effect and calls
+{@link android.support.v4.view.ViewCompat#postInvalidateOnAnimation postInvalidateOnAnimation()}
to trigger an invalidate on the view:</p>
<pre>// Edge effect / overscroll tracking objects.
@@ -250,7 +250,7 @@
boolean needsInvalidate = false;
- // The scroller isn't finished, meaning a fling or programmatic pan
+ // The scroller isn't finished, meaning a fling or programmatic pan
// operation is currently active.
if (mScroller.computeScrollOffset()) {
Point surfaceSize = computeScrollSurfaceSize();
@@ -262,7 +262,7 @@
boolean canScrollY = (mCurrentViewport.top > AXIS_Y_MIN
|| mCurrentViewport.bottom < AXIS_Y_MAX);
- /*
+ /*
* If you are zoomed in and currX or currY is
* outside of bounds and you're not already
* showing overscroll, then render the overscroll
@@ -272,7 +272,7 @@
&& currX < 0
&& mEdgeEffectLeft.isFinished()
&& !mEdgeEffectLeftActive) {
- mEdgeEffectLeft.onAbsorb((int)
+ mEdgeEffectLeft.onAbsorb((int)
OverScrollerCompat.getCurrVelocity(mScroller));
mEdgeEffectLeftActive = true;
needsInvalidate = true;
@@ -280,7 +280,7 @@
&& currX > (surfaceSize.x - mContentRect.width())
&& mEdgeEffectRight.isFinished()
&& !mEdgeEffectRightActive) {
- mEdgeEffectRight.onAbsorb((int)
+ mEdgeEffectRight.onAbsorb((int)
OverScrollerCompat.getCurrVelocity(mScroller));
mEdgeEffectRightActive = true;
needsInvalidate = true;
@@ -290,7 +290,7 @@
&& currY < 0
&& mEdgeEffectTop.isFinished()
&& !mEdgeEffectTopActive) {
- mEdgeEffectTop.onAbsorb((int)
+ mEdgeEffectTop.onAbsorb((int)
OverScrollerCompat.getCurrVelocity(mScroller));
mEdgeEffectTopActive = true;
needsInvalidate = true;
@@ -298,7 +298,7 @@
&& currY > (surfaceSize.y - mContentRect.height())
&& mEdgeEffectBottom.isFinished()
&& !mEdgeEffectBottomActive) {
- mEdgeEffectBottom.onAbsorb((int)
+ mEdgeEffectBottom.onAbsorb((int)
OverScrollerCompat.getCurrVelocity(mScroller));
mEdgeEffectBottomActive = true;
needsInvalidate = true;
@@ -316,14 +316,14 @@
// If a zoom is in progress (either programmatically or via double
// touch), performs the zoom.
if (mZoomer.computeZoom()) {
- float newWidth = (1f - mZoomer.getCurrZoom()) *
+ float newWidth = (1f - mZoomer.getCurrZoom()) *
mScrollerStartViewport.width();
- float newHeight = (1f - mZoomer.getCurrZoom()) *
+ float newHeight = (1f - mZoomer.getCurrZoom()) *
mScrollerStartViewport.height();
- float pointWithinViewportX = (mZoomFocalPoint.x -
+ float pointWithinViewportX = (mZoomFocalPoint.x -
mScrollerStartViewport.left)
/ mScrollerStartViewport.width();
- float pointWithinViewportY = (mZoomFocalPoint.y -
+ float pointWithinViewportY = (mZoomFocalPoint.y -
mScrollerStartViewport.top)
/ mScrollerStartViewport.height();
mCurrentViewport.set(
@@ -339,9 +339,9 @@
}
</pre>
-<p>This is the {@code computeScrollSurfaceSize()} method that's called in the above snippet. It
-computes the current scrollable surface size, in pixels. For example, if the entire chart area is visible,
-this is simply the current size of {@code mContentRect}. If the chart is zoomed in 200% in both directions,
+<p>This is the {@code computeScrollSurfaceSize()} method that's called in the above snippet. It
+computes the current scrollable surface size, in pixels. For example, if the entire chart area is visible,
+this is simply the current size of {@code mContentRect}. If the chart is zoomed in 200% in both directions,
the returned size will be twice as large horizontally and vertically.</p>
<pre>private Point computeScrollSurfaceSize() {
@@ -352,8 +352,8 @@
/ mCurrentViewport.height()));
}</pre>
-<p>For another example of scroller usage, see the
-<a href="http://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/view/ViewPager.java">source code</a> for the
-{@link android.support.v4.view.ViewPager} class. It scrolls in response to flings,
+<p>For another example of scroller usage, see the
+<a href="http://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/view/ViewPager.java">source code</a> for the
+{@link android.support.v4.view.ViewPager} class. It scrolls in response to flings,
and uses scrolling to implement the "snapping to page" animation.</p>
diff --git a/docs/html/training/gestures/viewgroup.jd b/docs/html/training/gestures/viewgroup.jd
index 5b32300..7b5b24e 100644
--- a/docs/html/training/gestures/viewgroup.jd
+++ b/docs/html/training/gestures/viewgroup.jd
@@ -52,38 +52,38 @@
<h2 id="intercept">Intercept Touch Events in a ViewGroup</h2>
-<p>The {@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
-method is called whenever a touch event is detected on the surface of a
-{@link android.view.ViewGroup}, including on the surface of its children. If
-{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
-returns {@code true}, the {@link android.view.MotionEvent} is intercepted,
-meaning it will be not be passed on to the child, but rather to the
+<p>The {@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
+method is called whenever a touch event is detected on the surface of a
+{@link android.view.ViewGroup}, including on the surface of its children. If
+{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
+returns {@code true}, the {@link android.view.MotionEvent} is intercepted,
+meaning it will be not be passed on to the child, but rather to the
{@link android.view.View#onTouchEvent onTouchEvent()} method of the parent.</p>
-<p>The {@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
-method gives a parent the chance to see any touch event before its children do.
-If you return {@code true} from
-{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()},
-the child view that was previously handling touch events
-receives an {@link android.view.MotionEvent#ACTION_CANCEL}, and the events from that
-point forward are sent to the parent's
-{@link android.view.View#onTouchEvent onTouchEvent()} method for the usual handling.
-{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()} can also
-return {@code false} and simply spy on events as they travel down the view hierarchy
+<p>The {@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}
+method gives a parent the chance to see any touch event before its children do.
+If you return {@code true} from
+{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()},
+the child view that was previously handling touch events
+receives an {@link android.view.MotionEvent#ACTION_CANCEL}, and the events from that
+point forward are sent to the parent's
+{@link android.view.View#onTouchEvent onTouchEvent()} method for the usual handling.
+{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()} can also
+return {@code false} and simply spy on events as they travel down the view hierarchy
to their usual targets, which will handle the events with their own
{@link android.view.View#onTouchEvent onTouchEvent()}.
-<p>In the following snippet, the class {@code MyViewGroup} extends
-{@link android.view.ViewGroup}.
-{@code MyViewGroup} contains multiple child views. If you drag your finger across
-a child view horizontally, the child view should no longer get touch events, and
-{@code MyViewGroup} should handle touch events by scrolling its contents. However,
-if you press buttons in the child view, or scroll the child view vertically,
-the parent shouldn't intercept those touch events, because the child is the
-intended target. In those cases,
+<p>In the following snippet, the class {@code MyViewGroup} extends
+{@link android.view.ViewGroup}.
+{@code MyViewGroup} contains multiple child views. If you drag your finger across
+a child view horizontally, the child view should no longer get touch events, and
+{@code MyViewGroup} should handle touch events by scrolling its contents. However,
+if you press buttons in the child view, or scroll the child view vertically,
+the parent shouldn't intercept those touch events, because the child is the
+intended target. In those cases,
{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()} should
-return {@code false}, and {@code MyViewGroup}'s
+return {@code false}, and {@code MyViewGroup}'s
{@link android.view.View#onTouchEvent onTouchEvent()} won't be called.</p>
<pre>public class MyViewGroup extends ViewGroup {
@@ -118,20 +118,20 @@
switch (action) {
case MotionEvent.ACTION_MOVE: {
if (mIsScrolling) {
- // We're currently scrolling, so yes, intercept the
+ // We're currently scrolling, so yes, intercept the
// touch event!
return true;
}
- // If the user has dragged her finger horizontally more than
+ // If the user has dragged her finger horizontally more than
// the touch slop, start the scroll
// left as an exercise for the reader
- final int xDiff = calculateDistanceX(ev);
+ final int xDiff = calculateDistanceX(ev);
- // Touch slop should be calculated using ViewConfiguration
+ // Touch slop should be calculated using ViewConfiguration
// constants.
- if (xDiff > mTouchSlop) {
+ if (xDiff > mTouchSlop) {
// Start scrolling!
mIsScrolling = true;
return true;
@@ -141,26 +141,26 @@
...
}
- // In general, we don't want to intercept touch events. They should be
+ // In general, we don't want to intercept touch events. They should be
// handled by the child view.
return false;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
- // Here we actually handle the touch event (e.g. if the action is ACTION_MOVE,
+ // Here we actually handle the touch event (e.g. if the action is ACTION_MOVE,
// scroll this container).
- // This method will only be called if the touch event was intercepted in
+ // This method will only be called if the touch event was intercepted in
// onInterceptTouchEvent
...
}
}</pre>
-<p>Note that {@link android.view.ViewGroup} also provides a
-{@link android.view.ViewGroup#requestDisallowInterceptTouchEvent requestDisallowInterceptTouchEvent()} method.
-The {@link android.view.ViewGroup} calls this method when a child does not want the parent and its
-ancestors to intercept touch events with
-{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}.
+<p>Note that {@link android.view.ViewGroup} also provides a
+{@link android.view.ViewGroup#requestDisallowInterceptTouchEvent requestDisallowInterceptTouchEvent()} method.
+The {@link android.view.ViewGroup} calls this method when a child does not want the parent and its
+ancestors to intercept touch events with
+{@link android.view.ViewGroup#onInterceptTouchEvent onInterceptTouchEvent()}.
</p>
<h2 id="vc">Use ViewConfiguration Constants</h2>
@@ -176,10 +176,10 @@
prevent accidental scrolling when the user is performing some other touch
operation, such as touching on-screen elements.</p>
-<p>Two other commonly used {@link android.view.ViewConfiguration} methods are
-{@link android.view.ViewConfiguration#getScaledMinimumFlingVelocity getScaledMinimumFlingVelocity()}
+<p>Two other commonly used {@link android.view.ViewConfiguration} methods are
+{@link android.view.ViewConfiguration#getScaledMinimumFlingVelocity getScaledMinimumFlingVelocity()}
and {@link android.view.ViewConfiguration#getScaledMaximumFlingVelocity getScaledMaximumFlingVelocity()}.
-These methods return the minimum and maximum velocity (respectively) to initiate a fling,
+These methods return the minimum and maximum velocity (respectively) to initiate a fling,
as measured in pixels per second. For example:</p>
<pre>ViewConfiguration vc = ViewConfiguration.get(view.getContext());
@@ -209,14 +209,14 @@
<h2 id="delegate">Extend a Child View's Touchable Area</h2>
-<p>Android provides the {@link android.view.TouchDelegate} class to make it possible
-for a parent to extend the touchable area of a child view beyond the child's bounds.
+<p>Android provides the {@link android.view.TouchDelegate} class to make it possible
+for a parent to extend the touchable area of a child view beyond the child's bounds.
This is useful when the child has to be small, but should have a larger touch region. You can
also use this approach to shrink the child's touch region if need be.</p>
-<p>In the following example, an {@link android.widget.ImageButton} is the
-"delegate view" (that is, the child whose touch area the parent will extend).
+<p>In the following example, an {@link android.widget.ImageButton} is the
+"delegate view" (that is, the child whose touch area the parent will extend).
Here is the layout file:</p>
<pre>
@@ -225,7 +225,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
-
+
<ImageButton android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -245,9 +245,9 @@
</ul>
-In its capacity as touch delegate for the {@link android.widget.ImageButton} child view, the
+In its capacity as touch delegate for the {@link android.widget.ImageButton} child view, the
parent view will receive all touch events. If the touch event occurred within the child's hit
-rectangle, the parent will pass the touch
+rectangle, the parent will pass the touch
event to the child for handling.</p>
@@ -261,7 +261,7 @@
setContentView(R.layout.activity_main);
// Get the parent view
View parentView = findViewById(R.id.parent_layout);
-
+
parentView.post(new Runnable() {
// Post in the parent's message queue to make sure the parent
// lays out its children before you call getHitRect()
@@ -275,29 +275,29 @@
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Toast.makeText(MainActivity.this,
- "Touch occurred within ImageButton touch region.",
+ Toast.makeText(MainActivity.this,
+ "Touch occurred within ImageButton touch region.",
Toast.LENGTH_SHORT).show();
}
});
-
+
// The hit rectangle for the ImageButton
myButton.getHitRect(delegateArea);
-
+
// Extend the touch area of the ImageButton beyond its bounds
// on the right and bottom.
delegateArea.right += 100;
delegateArea.bottom += 100;
-
+
// Instantiate a TouchDelegate.
- // "delegateArea" is the bounds in local coordinates of
+ // "delegateArea" is the bounds in local coordinates of
// the containing view to be mapped to the delegate view.
// "myButton" is the child view that should receive motion
// events.
- TouchDelegate touchDelegate = new TouchDelegate(delegateArea,
+ TouchDelegate touchDelegate = new TouchDelegate(delegateArea,
myButton);
-
- // Sets the TouchDelegate on the parent view, such that touches
+
+ // Sets the TouchDelegate on the parent view, such that touches
// within the touch delegate bounds are routed to the child.
if (View.class.isInstance(myButton.getParent())) {
((View) myButton.getParent()).setTouchDelegate(touchDelegate);
diff --git a/docs/html/training/id-auth/authenticate.jd b/docs/html/training/id-auth/authenticate.jd
index 65dbc39..bf32e8e 100644
--- a/docs/html/training/id-auth/authenticate.jd
+++ b/docs/html/training/id-auth/authenticate.jd
@@ -129,7 +129,7 @@
public void run(AccountManagerFuture<Bundle> result) {
// Get the result of the operation from the AccountManagerFuture.
Bundle bundle = result.getResult();
-
+
// The token is a named value in the bundle. The name of the value
// is stored in the constant AccountManager.KEY_AUTHTOKEN.
token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
diff --git a/docs/html/training/id-auth/custom_auth.jd b/docs/html/training/id-auth/custom_auth.jd
index def9b51..3c106a9 100644
--- a/docs/html/training/id-auth/custom_auth.jd
+++ b/docs/html/training/id-auth/custom_auth.jd
@@ -81,7 +81,7 @@
credentials would be readable by anyone with {@code adb} access to the device.</p>
<p>With this in mind, you shouldn't pass the user's actual
-password to {@link android.accounts.AccountManager#addAccountExplicitly
+password to {@link android.accounts.AccountManager#addAccountExplicitly
AccountManager.addAccountExplicitly()}. Instead, you should store a
cryptographically secure token that would be of limited use to an attacker. If your
user credentials are protecting something valuable, you should carefully
diff --git a/docs/html/training/id-auth/index.jd b/docs/html/training/id-auth/index.jd
index f15ee29..45c6309 100644
--- a/docs/html/training/id-auth/index.jd
+++ b/docs/html/training/id-auth/index.jd
@@ -15,7 +15,7 @@
<li>Android 2.0 (API level 5) or higher</li>
<li>Experience with <a href="{@docRoot}guide/components/services.html">Services</a></li>
<li>Experience with <a href="http://oauth.net/2/">OAuth 2.0</a></li>
-</ul>
+</ul>
<h2>You should also read</h2>
<ul>
diff --git a/docs/html/training/improving-layouts/optimizing-layout.jd b/docs/html/training/improving-layouts/optimizing-layout.jd
index e0baedf..2f9f32d 100644
--- a/docs/html/training/improving-layouts/optimizing-layout.jd
+++ b/docs/html/training/improving-layouts/optimizing-layout.jd
@@ -145,7 +145,7 @@
<li>Deep layouts - Layouts with too much nesting are bad for performance. Consider using flatter layouts such as {@link android.widget.RelativeLayout} or {@link android.widget.GridLayout} to improve performance. The default maximum depth is 10.</li>
</ul>
-<p>Another benefit of Lint is that it is integrated into Android Studio. Lint automatically runs
+<p>Another benefit of Lint is that it is integrated into Android Studio. Lint automatically runs
whenever you compile your program. With Android Studio, you can also run lint inspections for a
specific build variant, or for all build variants. </p>
@@ -153,7 +153,7 @@
<strong>File>Settings>Project Settings</strong> option. The Inspection Configuration page
appears with the supported inspections.</p>
<p><img src="{@docRoot}images/tools/studio-inspections-config.png" alt="" /> </p>
-<p class="img-caption"><strong>Figure 5.</strong> Inspection Configuration</p>
+<p class="img-caption"><strong>Figure 5.</strong> Inspection Configuration</p>
<p>Lint has the ability to automatically fix some issues, provide suggestions for others and jump
directly to the offending code for review.</p>
diff --git a/docs/html/training/in-app-billing/list-iab-products.jd b/docs/html/training/in-app-billing/list-iab-products.jd
index c423fc1..c8de823 100644
--- a/docs/html/training/in-app-billing/list-iab-products.jd
+++ b/docs/html/training/in-app-billing/list-iab-products.jd
@@ -36,7 +36,7 @@
<p>To add new in-app products to your product list:</p>
<ol>
-<li>Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see <a href="{@docRoot}tools/publishing/preparing.html#publishing-build">Building Your Application for Release</a>. Make sure that you are using your final (not debug) certificate and private key to sign your application.
+<li>Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see <a href="{@docRoot}tools/publishing/preparing.html#publishing-build">Building Your Application for Release</a>. Make sure that you are using your final (not debug) certificate and private key to sign your application.
</li>
<li>In the Developer Console, open the application entry that you created earlier.</li>
<li>Click on the APK tab then click on Upload new APK. Upload the signed APK file to the Developer Console. Don’t publish the app yet!</li>
@@ -48,9 +48,9 @@
<h2 id="QueryDetails">Query Items Available for Purchase</h2>
<p>You can query Google Play to programmatically retrieve details of the in-app products that are associated with your application (such as the product’s price, title, description, and type). This is useful, for example, when you want to display a listing of unowned items that are still available for purchase to users.</p>
<p class="note"><strong>Note:</strong> When making the query, you will need to specify the product IDs for the products explicitly. You can manually find the product IDs from the Developer Console by opening the <strong>In-app Products</strong> tab for your application. The product IDs are listed under the column labeled <strong>Name/ID</strong>.</p>
-<p>To retrieve the product details, call {@code queryInventoryAsync(boolean, List, QueryInventoryFinishedListener)} on your IabHelper instance.
+<p>To retrieve the product details, call {@code queryInventoryAsync(boolean, List, QueryInventoryFinishedListener)} on your IabHelper instance.
<ul>
-<li>The first input argument indicates whether product details should be retrieved (should be set to {@code true}).</li>
+<li>The first input argument indicates whether product details should be retrieved (should be set to {@code true}).</li>
<li>The {@code List} argument consists of one or more product IDs (also called SKUs) for the products that you want to query.</li>
<li>Finally, the {@code QueryInventoryFinishedListener} argument specifies a listener is notified when the query operation has completed and handles the query response.</li>
</ul>
@@ -70,9 +70,9 @@
<p>The following code shows how you can retrieve the item prices from the result set.</p>
<pre>
-IabHelper.QueryInventoryFinishedListener
+IabHelper.QueryInventoryFinishedListener
mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
- public void onQueryInventoryFinished(IabResult result, Inventory inventory)
+ public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
// handle error
@@ -84,7 +84,7 @@
String bananaPrice =
inventory.getSkuDetails(SKU_BANANA).getPrice();
- // update the UI
+ // update the UI
}
}
</pre>
diff --git a/docs/html/training/in-app-billing/purchase-iab-products.jd b/docs/html/training/in-app-billing/purchase-iab-products.jd
index 4e6e035..165e311 100644
--- a/docs/html/training/in-app-billing/purchase-iab-products.jd
+++ b/docs/html/training/in-app-billing/purchase-iab-products.jd
@@ -45,7 +45,7 @@
<p>The following example shows how you can make a purchase request for a product with ID {@code SKU_GAS}, using an arbitrary value of 10001 for the request code, and an encoded developer payload string.</p>
<pre>
-mHelper.launchPurchaseFlow(this, SKU_GAS, 10001,
+mHelper.launchPurchaseFlow(this, SKU_GAS, 10001,
mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
</pre>
@@ -54,14 +54,14 @@
<p>The following example shows how you can handle the purchase response in the listener, depending on whether the purchase order was completed successfully, and whether the user purchased gas or a premium upgrade. In this example, gas is an in-app product that can be purchased multiple times, so you should consume the purchase to allow the user to buy it again. To learn how to consume purchases, see the <a href="{@docRoot}training/in-app-billing/purchase-iab-products.html#Consume">Consuming Products</a> section. The premium upgrade is a one-time purchase so you don’t need to consume it. It is good practice to update the UI immediately so that your users can see their newly purchased items.</p>
<pre>
-IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
+IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
- public void onIabPurchaseFinished(IabResult result, Purchase purchase)
+ public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
- }
+ }
else if (purchase.getSku().equals(SKU_GAS)) {
// consume the gas and update the UI
}
@@ -86,7 +86,7 @@
<p>If the query is successful, the query results are stored in an {@code Inventory} object that is passed back to the listener. The In-app Billing service returns only the purchases made by the user account that is currently logged in to the device.</p>
<pre>
-IabHelper.QueryInventoryFinishedListener mGotInventoryListener
+IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
@@ -96,7 +96,7 @@
}
else {
// does the user have the premium upgrade?
- mIsPremium = inventory.hasPurchase(SKU_PREMIUM);
+ mIsPremium = inventory.hasPurchase(SKU_PREMIUM);
// update UI accordingly
}
}
@@ -111,7 +111,7 @@
<p>In this example, you want to consume the gas item that the user has previously purchased in your app.</p>
<pre>
-mHelper.consumeAsync(inventory.getPurchase(SKU_GAS),
+mHelper.consumeAsync(inventory.getPurchase(SKU_GAS),
mConsumeFinishedListener);
</pre>
diff --git a/docs/html/training/in-app-billing/test-iab-app.jd b/docs/html/training/in-app-billing/test-iab-app.jd
index 9d47a96..fc7fe1a 100644
--- a/docs/html/training/in-app-billing/test-iab-app.jd
+++ b/docs/html/training/in-app-billing/test-iab-app.jd
@@ -39,7 +39,7 @@
<li>Login to the <a href="https://play.google.com/apps/publish/" target="_blank">Developer Console</a> with your developer account.</li>
<li>Click <strong>Settings</strong> > <strong>Account</strong> details, then in the <strong>License Testing</strong> section, add the Google email addresses for your tester accounts.</li>
</ol>
-<li>Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see <a href="{@docRoot}tools/publishing/preparing.html#publishing-build">Building Your Application for Release</a>. Make sure that you are using your final (not debug) certificate and private key to sign your application.
+<li>Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see <a href="{@docRoot}tools/publishing/preparing.html#publishing-build">Building Your Application for Release</a>. Make sure that you are using your final (not debug) certificate and private key to sign your application.
</li>
<li>Make sure that you have uploaded the signed APK for your application to the Developer Console, and associated one or more in-app products with your application. You don't need to publish the application on Google Play to test it. <p class="note"><strong>Warning:</strong> It may take up to 2-3 hours after uploading the APK for Google Play to recognize your updated APK version. If you try to test your application before your uploaded APK is recognized by Google Play, your application will receive a ‘purchase cancelled’ response with an error message “This version of the application is not enabled for In-app Billing.”</p></li>
<li>Install the APK file to your physical test device by using the {@code adb} tool. To learn how to install the application, see <a href="{@docRoot}tools/building/building-cmdline.html#RunningOnDevice">Running on a Device</a>. Make sure that:
diff --git a/docs/html/training/keyboard-input/index.jd b/docs/html/training/keyboard-input/index.jd
index 46795c4..bd7ad18 100644
--- a/docs/html/training/keyboard-input/index.jd
+++ b/docs/html/training/keyboard-input/index.jd
@@ -32,9 +32,9 @@
<p>These topics and more are discussed in the following lessons.</p>
-<h2>Lessons</h2>
-
-<dl>
+<h2>Lessons</h2>
+
+<dl>
<dt><b><a href="style.html">Specifying the Input Method Type</a></b></dt>
<dd>Learn how to show certain soft input methods, such as those designed for phone numbers, web
addresses, or other formats. Also learn how to specify characteristics such
@@ -51,5 +51,5 @@
<dt><b><a href="commands.html">Handling Keyboard Actions</a></b></dt>
<dd>Learn how to respond directly to keyboard input for user actions.
</dd>
-
-</dl>
+
+</dl>
diff --git a/docs/html/training/keyboard-input/style.jd b/docs/html/training/keyboard-input/style.jd
index b0e506c..714c8b3 100644
--- a/docs/html/training/keyboard-input/style.jd
+++ b/docs/html/training/keyboard-input/style.jd
@@ -71,7 +71,7 @@
android:id="@+id/password"
android:hint="@string/password_hint"
android:inputType="textPassword"
- ... />
+ ... />
</pre>
<p>There are several possible values documented with the
diff --git a/docs/html/training/load-data-background/handle-results.jd b/docs/html/training/load-data-background/handle-results.jd
index ce0024f..7439d3e 100644
--- a/docs/html/training/load-data-background/handle-results.jd
+++ b/docs/html/training/load-data-background/handle-results.jd
@@ -127,7 +127,7 @@
*/
@Override
public void onLoaderReset(Loader<Cursor> loader) {
-
+
/*
* Clears out the adapter's reference to the Cursor.
* This prevents memory leaks.
diff --git a/docs/html/training/location/display-address.jd b/docs/html/training/location/display-address.jd
index 8606629..daa6fd3 100644
--- a/docs/html/training/location/display-address.jd
+++ b/docs/html/training/location/display-address.jd
@@ -324,7 +324,7 @@
process if needed. If the service is already running then it remains running.
Because the service extends {@link android.app.IntentService IntentService},
it shuts down automatically when all intents have been processed.</p>
-
+
<p>Start the service from your app's main activity,
and create an {@link android.content.Intent} to pass data to the service. You
need an <em>explicit</em> intent, because you want only your service
diff --git a/docs/html/training/location/geofencing.jd b/docs/html/training/location/geofencing.jd
index 1cf89fd..ce6ad55 100644
--- a/docs/html/training/location/geofencing.jd
+++ b/docs/html/training/location/geofencing.jd
@@ -369,7 +369,7 @@
GEOFENCE_TRANSITION_DWELL</a></code> instead of <code>
<a href="{@docRoot}reference/com/google/android/gms/location/Geofence.html#GEOFENCE_TRANSITION_ENTER">
GEOFENCE_TRANSITION_ENTER</a></code>. This way, the dwelling alert is sent only when the user stops
-inside a geofence for a given period of time. You can choose the duration by setting a
+inside a geofence for a given period of time. You can choose the duration by setting a
<a href="{@docRoot}reference/com/google/android/gms/location/Geofence.Builder.html#setLoiteringDelay(int)">
loitering delay</a>.</p>
diff --git a/docs/html/training/managing-audio/audio-output.jd b/docs/html/training/managing-audio/audio-output.jd
index 416e519..ed1623b 100644
--- a/docs/html/training/managing-audio/audio-output.jd
+++ b/docs/html/training/managing-audio/audio-output.jd
@@ -8,8 +8,8 @@
@jd:body
-
-<div id="tb-wrapper">
+
+<div id="tb-wrapper">
<div id="tb">
<h2>This lesson teaches you to</h2>
@@ -25,16 +25,16 @@
</ul>
-</div>
+</div>
</div>
<p>Users have a number of alternatives when it comes to enjoying the audio from their Android
devices. Most devices have a built-in speaker, headphone jacks for wired headsets, and many also
feature Bluetooth connectivity and support for A2DP audio. </p>
-
-<h2 id="CheckHardware">Check What Hardware is Being Used</h2>
-
+
+<h2 id="CheckHardware">Check What Hardware is Being Used</h2>
+
<p>How your app behaves might be affected by which hardware its output is being routed to.</p>
<p>You can query the {@link android.media.AudioManager} to determine if the audio is currently
@@ -48,13 +48,13 @@
// Adjust output for Speakerphone.
} else if (isWiredHeadsetOn()) {
// Adjust output for headsets
-} else {
+} else {
// If audio plays and noone can hear it, is it still playing?
}
</pre>
-<h2 id="HandleChanges">Handle Changes in the Audio Output Hardware</h2>
+<h2 id="HandleChanges">Handle Changes in the Audio Output Hardware</h2>
<p>When a headset is unplugged, or a Bluetooth device disconnected, the audio stream
automatically reroutes to the built in speaker. If you listen to your music at as high a volume as I
@@ -65,7 +65,7 @@
that listens for this intent whenever you’re playing audio. In the case of music players, users
typically expect the playback to be paused—while for games you may choose to significantly
lower the volume.</p>
-
+
<pre>
private class NoisyAudioStreamReceiver extends BroadcastReceiver {
@Override
diff --git a/docs/html/training/managing-audio/index.jd b/docs/html/training/managing-audio/index.jd
index 9391449..55b91c2 100644
--- a/docs/html/training/managing-audio/index.jd
+++ b/docs/html/training/managing-audio/index.jd
@@ -6,10 +6,10 @@
@jd:body
-<div id="tb-wrapper">
+<div id="tb-wrapper">
<div id="tb">
-<h2>Dependencies and prerequisites</h2>
+<h2>Dependencies and prerequisites</h2>
<ul>
<li>Android 2.0 (API level 5) or higher</li>
<li>Experience with <a href="{@docRoot}guide/topics/media/mediaplayer.html">Media
@@ -21,41 +21,41 @@
<li><a href="{@docRoot}guide/components/services.html">Services</a></li>
</ul>
-</div>
+</div>
</div>
<p>If your app plays audio, it’s important that your users can control the audio in a predictable
manner. To ensure a great user experience, it’s also important that your app manages the audio focus
-to ensure multiple apps aren’t playing audio at the same time.</p>
+to ensure multiple apps aren’t playing audio at the same time.</p>
-<p>After this class, you will be able to build apps that respond to hardware audio key presses,
+<p>After this class, you will be able to build apps that respond to hardware audio key presses,
which request audio focus when playing audio, and which respond appropriately to changes in audio
-focus caused by the system or other applications.</p>
+focus caused by the system or other applications.</p>
-<h2>Lessons</h2>
-
+<h2>Lessons</h2>
+
<!-- Create a list of the lessons in this class along with a short description of each lesson.
These should be short and to the point. It should be clear from reading the summary whether someone
-will want to jump to a lesson or not.-->
-
+will want to jump to a lesson or not.-->
+
<dl>
<dt><b><a href="volume-playback.html">Controlling Your App’s Volume and
Playback</a></b></dt>
<dd>Learn how to ensure your users can control the volume of your app using the hardware or
software volume controls and where available the play, stop, pause, skip, and previous media
-playback keys.</dd>
-
+playback keys.</dd>
+
<dt><b><a href="audio-focus.html">Managing Audio Focus</a></b></dt>
<dd>With multiple apps potentially playing audio it's important to think about how they should
interact. To avoid every music app playing at the same time, Android uses audio focus to moderate
audio playback. Learn how to request the audio focus, listen for a loss of audio focus, and how to
-respond when that happens.</dd>
-
+respond when that happens.</dd>
+
<dt><b><a href="audio-output.html">Dealing with Audio Output Hardware</a></b></dt>
<dd>Audio can be played from a number of sources. Learn how to find out where the audio is being
-played and how to handle a headset being disconnected during playback.</dd>
- </dl>
+played and how to handle a headset being disconnected during playback.</dd>
+ </dl>
diff --git a/docs/html/training/managing-audio/volume-playback.jd b/docs/html/training/managing-audio/volume-playback.jd
index be0f583..7e28893 100644
--- a/docs/html/training/managing-audio/volume-playback.jd
+++ b/docs/html/training/managing-audio/volume-playback.jd
@@ -8,8 +8,8 @@
@jd:body
-
-<div id="tb-wrapper">
+
+<div id="tb-wrapper">
<div id="tb">
<h2>This lesson teaches you to</h2>
@@ -26,11 +26,11 @@
<li><a href="{@docRoot}guide/topics/media/mediaplayer.html">Media Playback</a></li>
</ul>
-</div>
+</div>
</div>
-
+
<p>A good user experience is a predictable one. If your app plays media it’s important that your
users can control the volume of your app using the hardware or software volume controls of their
device, bluetooth headset, or headphones.</p>
@@ -38,9 +38,9 @@
<p>Similarly, where appropriate and available, the play, stop, pause, skip, and previous media
playback keys should perform their respective actions on the audio stream used by your app.</p>
-
-<h2 id="IdentifyStream">Identify Which Audio Stream to Use</h2>
-
+
+<h2 id="IdentifyStream">Identify Which Audio Stream to Use</h2>
+
<p>The first step to creating a predictable audio experience is understanding which audio stream
your app will use.</p>
@@ -53,11 +53,11 @@
android.media.AudioManager#STREAM_MUSIC} stream.</p>
-<h2 id="HardwareVolumeKeys">Use Hardware Volume Keys to Control Your App’s Audio Volume</h2>
+<h2 id="HardwareVolumeKeys">Use Hardware Volume Keys to Control Your App’s Audio Volume</h2>
<p>By default, pressing the volume controls modify the volume of the active audio stream. If your
app isn't currently playing anything, hitting the volume keys adjusts the ringer volume.<p>
-
+
<p>If you've got a game or music app, then chances are good that when the user hits the volume keys
they want to control the volume of the game or music, even if they’re currently between songs or
there’s no music in the current game location.</p>
@@ -65,8 +65,8 @@
<p>You may be tempted to try and listen for volume key presses and modify the volume of your
audio stream that way. Resist the urge. Android provides the handy {@link
android.app.Activity#setVolumeControlStream setVolumeControlStream()} method to direct volume key
-presses to the audio stream you specify.<p>
-
+presses to the audio stream you specify.<p>
+
<p>Having identified the audio stream your application
will be using, you should set it as the volume stream target. You should make this call early in
your app’s lifecycle—because you only need to call it once during the activity lifecycle, you
@@ -85,7 +85,7 @@
<h2 id="PlaybackControls">Use Hardware Playback Control Keys to Control Your App’s Audio
-Playback</h2>
+Playback</h2>
<p>Media playback buttons such as play, pause, stop, skip, and previous are available on some
handsets and many connected or wireless headsets. Whenever a user presses one of these hardware
diff --git a/docs/html/training/monitoring-device-state/connectivity-monitoring.jd b/docs/html/training/monitoring-device-state/connectivity-monitoring.jd
index d5e7a85..2dd904f 100644
--- a/docs/html/training/monitoring-device-state/connectivity-monitoring.jd
+++ b/docs/html/training/monitoring-device-state/connectivity-monitoring.jd
@@ -11,7 +11,7 @@
@jd:body
-<div id="tb-wrapper">
+<div id="tb-wrapper">
<div id="tb">
<h2>This lesson teaches you to</h2>
@@ -27,7 +27,7 @@
<li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>
</ul>
-</div>
+</div>
</div>
<p>Some of the most common uses for repeating alarms and background services is to schedule regular
@@ -39,21 +39,21 @@
connected to the Internet, and if so, what type of connection is in place.</p>
-<h2 id="DetermineConnection">Determine if You Have an Internet Connection</h2>
-
+<h2 id="DetermineConnection">Determine if You Have an Internet Connection</h2>
+
<p>There's no need to schedule an update based on an Internet resource if you aren't connected to
-the Internet. The following snippet shows how to use the {@link android.net.ConnectivityManager}
+the Internet. The following snippet shows how to use the {@link android.net.ConnectivityManager}
to query the active network and determine if it has Internet connectivity.</p>
<pre>ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
-
+
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();</pre>
-<h2 id="DetermineType">Determine the Type of your Internet Connection</h2>
+<h2 id="DetermineType">Determine the Type of your Internet Connection</h2>
<p>It's also possible to determine the type of Internet connection currently available.</p>
@@ -71,7 +71,7 @@
to resume them once an Internet connection has been established.</p>
-<h2 id="MonitorChanges">Monitor for Changes in Connectivity</h2>
+<h2 id="MonitorChanges">Monitor for Changes in Connectivity</h2>
<p>The {@link android.net.ConnectivityManager} broadcasts the {@link
android.net.ConnectivityManager#CONNECTIVITY_ACTION} ({@code
diff --git a/docs/html/training/monitoring-device-state/manifest-receivers.jd b/docs/html/training/monitoring-device-state/manifest-receivers.jd
index ca184aa5..3e36dba 100644
--- a/docs/html/training/monitoring-device-state/manifest-receivers.jd
+++ b/docs/html/training/monitoring-device-state/manifest-receivers.jd
@@ -9,7 +9,7 @@
@jd:body
-<div id="tb-wrapper">
+<div id="tb-wrapper">
<div id="tb">
<h2>This lesson teaches you to</h2>
@@ -24,7 +24,7 @@
<li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>
</ul>
-</div>
+</div>
</div>
<p>The simplest way to monitor device state changes is to create a {@link
@@ -38,10 +38,10 @@
<p>A better approach is to disable or enable the broadcast receivers at runtime. That way you can
use the receivers you declared in the manifest as passive alarms that are triggered by system events
only when necessary.</p>
-
-<h2 id="ToggleReceivers">Toggle and Cascade State Change Receivers to Improve Efficiency </h2>
-
+
+<h2 id="ToggleReceivers">Toggle and Cascade State Change Receivers to Improve Efficiency </h2>
+
<p>You can use the {@link android.content.pm.PackageManager} to toggle the enabled state on any
component defined in the manifest, including whichever broadcast receivers you wish to enable or
disable as shown in the snippet below:</p>
@@ -59,6 +59,6 @@
stop listening for connectivity changes and simply check to see if you're online immediately before
performing an update and rescheduling a recurring update alarm.</p>
-<p>You can use the same technique to delay a download that requires higher bandwidth to complete.
+<p>You can use the same technique to delay a download that requires higher bandwidth to complete.
Simply enable a broadcast receiver that listens for connectivity changes and initiates the
download only after you are connected to Wi-Fi.</p>
diff --git a/docs/html/training/multiple-threads/create-threadpool.jd b/docs/html/training/multiple-threads/create-threadpool.jd
index e22afd3..df28833 100644
--- a/docs/html/training/multiple-threads/create-threadpool.jd
+++ b/docs/html/training/multiple-threads/create-threadpool.jd
@@ -48,7 +48,7 @@
also occurs in any object that is only instantiated once. To learn more about this, read the
<a href="{@docRoot}guide/components/processes-and-threads.html">
Processes and Threads</a> API guide.
-
+
</p>
<h2 id="ClassStructure">Define the Thread Pool Class</h2>
<p>
diff --git a/docs/html/training/multiscreen/adaptui.jd b/docs/html/training/multiscreen/adaptui.jd
index 34e9d7d..469012b 100644
--- a/docs/html/training/multiscreen/adaptui.jd
+++ b/docs/html/training/multiscreen/adaptui.jd
@@ -10,9 +10,9 @@
<!-- This is the training bar -->
-<div id="tb-wrapper">
-<div id="tb">
-
+<div id="tb-wrapper">
+<div id="tb">
+
<h2>This lesson teaches you to</h2>
<ol>
@@ -28,18 +28,18 @@
<li><a href="{@docRoot}guide/practices/tablets-and-handsets.html">Supporting Tablets and
Handsets</a></li>
</ul>
-
+
<h2>Try it out</h2>
-
+
<div class="download-box">
<a href="http://developer.android.com/shareables/training/NewsReader.zip" class="button">Download
the sample app</a>
-<p class="filename">NewsReader.zip</p>
-</div>
-
-
-</div>
-</div>
+<p class="filename">NewsReader.zip</p>
+</div>
+
+
+</div>
+</div>
<p>Depending on the layout that your application is currently showing, the UI
flow may be different. For example, if your application is in the dual-pane
@@ -66,7 +66,7 @@
setContentView(R.layout.main_layout);
View articleView = findViewById(R.id.article);
- mIsDualPane = articleView != null &&
+ mIsDualPane = articleView != null &&
articleView.getVisibility() == View.VISIBLE;
}
}
@@ -139,7 +139,7 @@
else {
/* use list navigation (spinner) */
actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
- SpinnerAdapter adap = new ArrayAdapter<String>(this,
+ SpinnerAdapter adap = new ArrayAdapter<String>(this,
R.layout.headline_item, CATEGORIES);
actionBar.setListNavigationCallbacks(adap, handler);
}
@@ -157,7 +157,7 @@
<p>In cases like this, you can usually avoid code duplication by reusing the
same {@link android.app.Fragment} subclass in several activities. For example,
-<code>ArticleFragment</code>
+<code>ArticleFragment</code>
is used in the dual-pane layout:</p>
{@sample development/samples/training/multiscreen/newsreader/res/layout/twopanes.xml all}
@@ -206,7 +206,7 @@
public class HeadlinesFragment extends ListFragment {
...
@Override
- public void onItemClick(AdapterView<?> parent,
+ public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
if (null != mHeadlineSelectedListener) {
mHeadlineSelectedListener.onHeadlineSelected(position);
diff --git a/docs/html/training/multiscreen/index.jd b/docs/html/training/multiscreen/index.jd
index 8eff246..2c59fac 100644
--- a/docs/html/training/multiscreen/index.jd
+++ b/docs/html/training/multiscreen/index.jd
@@ -7,10 +7,10 @@
@jd:body
-<div id="tb-wrapper">
-<div id="tb">
-
-<h2>Dependencies and prerequisites</h2>
+<div id="tb-wrapper">
+<div id="tb">
+
+<h2>Dependencies and prerequisites</h2>
<ul>
<li>Android 1.6 or higher (2.1+ for the sample app)</li>
@@ -28,18 +28,18 @@
<ul>
<li><a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li>
</ul>
-
-<h2>Try it out</h2>
-
-<div class="download-box">
+
+<h2>Try it out</h2>
+
+<div class="download-box">
<a href="http://developer.android.com/shareables/training/NewsReader.zip" class="button">Download
the sample app</a>
-<p class="filename">NewsReader.zip</p>
-</div>
-
-</div>
-</div>
-
+<p class="filename">NewsReader.zip</p>
+</div>
+
+</div>
+</div>
+
<p>Android powers hundreds of device types with several different screen sizes,
ranging from small phones to large TV sets. Therefore, it’s important
that you design your application to be compatible with all screen sizes so it’s available to as many
@@ -62,26 +62,26 @@
href="{@docRoot}tools/support-library/index.html">support library</a> in order to use the {@link
android.app.Fragment} APIs on versions lower than Android 3.0. You must download and add the
library to your application in order to use all APIs in this class.</p>
-
-<h2>Lessons</h2>
-
-<dl>
- <dt><b><a href="screensizes.html">Supporting Different Screen Sizes</a></b></dt>
+
+<h2>Lessons</h2>
+
+<dl>
+ <dt><b><a href="screensizes.html">Supporting Different Screen Sizes</a></b></dt>
<dd>This lesson walks you through how to design layouts that adapts
several different screen sizes (using flexible dimensions for
views, {@link android.widget.RelativeLayout}, screen size and orientation qualifiers,
- alias filters, and nine-patch bitmaps).</dd>
-
+ alias filters, and nine-patch bitmaps).</dd>
+
<dt><b><a href="screendensities.html">Supporting Different Screen
- Densities</a></b></dt>
+ Densities</a></b></dt>
<dd>This lesson shows you how to support screens that have different
pixel densities (using density-independent pixels and providing
- bitmaps appropriate for each density).</dd>
-
- <dt><b><a href="adaptui.html">Implementing Adaptative UI Flows</a></b></dt>
+ bitmaps appropriate for each density).</dd>
+
+ <dt><b><a href="adaptui.html">Implementing Adaptative UI Flows</a></b></dt>
<dd>This lesson shows you how to implement your UI flow in a way
that adapts to several screen size/density combinations
(run-time detection of active layout, reacting according to
- current layout, handling screen configuration changes).</dd>
-</dl>
+ current layout, handling screen configuration changes).</dd>
+</dl>
diff --git a/docs/html/training/multiscreen/screensizes.jd b/docs/html/training/multiscreen/screensizes.jd
index 2cd59ee..040bb85 100755
--- a/docs/html/training/multiscreen/screensizes.jd
+++ b/docs/html/training/multiscreen/screensizes.jd
@@ -10,8 +10,8 @@
<!-- This is the training bar -->
-<div id="tb-wrapper">
-<div id="tb">
+<div id="tb-wrapper">
+<div id="tb">
<h2>This lesson teaches you to</h2>
<ol>
@@ -30,27 +30,27 @@
<li><a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li>
</ul>
-<h2>Try it out</h2>
-
-<div class="download-box">
+<h2>Try it out</h2>
+
+<div class="download-box">
<a href="http://developer.android.com/shareables/training/NewsReader.zip" class="button">Download
the sample app</a>
-<p class="filename">NewsReader.zip</p>
-</div>
-
-</div>
-</div>
+<p class="filename">NewsReader.zip</p>
+</div>
+
+</div>
+</div>
<p>This lesson shows you how to support different screen sizes by:</p>
-<ul>
- <li>Ensuring your layout can be adequately resized to fit the screen</li>
- <li>Providing appropriate UI layout according to screen configuration</li>
+<ul>
+ <li>Ensuring your layout can be adequately resized to fit the screen</li>
+ <li>Providing appropriate UI layout according to screen configuration</li>
<li>Ensuring the correct layout is applied to the correct screen</li>
- <li>Providing bitmaps that scale correctly</li>
-</ul>
+ <li>Providing bitmaps that scale correctly</li>
+</ul>
-<h2 id="TaskUseWrapMatchPar">Use "wrap_content" and "match_parent"</h2>
+<h2 id="TaskUseWrapMatchPar">Use "wrap_content" and "match_parent"</h2>
<p>To ensure that your layout is flexible and adapts to different screen sizes,
you should use <code>"wrap_content"</code> and <code>"match_parent"</code> for the width
@@ -78,11 +78,11 @@
and landscape (right).</p>
-<h2 id="TaskUseRelativeLayout">Use RelativeLayout</h2>
+<h2 id="TaskUseRelativeLayout">Use RelativeLayout</h2>
<p>You can construct fairly complex layouts using nested instances of {@link
android.widget.LinearLayout} and
-combinations of <code>"wrap_content"</code> and <code>"match_parent"</code> sizes.
+combinations of <code>"wrap_content"</code> and <code>"match_parent"</code> sizes.
However, {@link android.widget.LinearLayout} does not allow you to precisely control the
spacial relationships of child views; views in a {@link android.widget.LinearLayout} simply line up
side-by-side. If you need child views to be oriented in variations other than a straight line, a
@@ -139,8 +139,8 @@
spatial relationships are preserved as specified by the {@link
android.widget.RelativeLayout.LayoutParams}.</p>
-
-<h2 id="TaskUseSizeQuali">Use Size Qualifiers</h2>
+
+<h2 id="TaskUseSizeQuali">Use Size Qualifiers</h2>
<p>There's only so much mileage you can get from a flexible layout or relative layout
like the one in the previous sections. While those layouts adapt to
@@ -148,7 +148,7 @@
may not provide the best user experience for each screen size. Therefore, your
application should not only implement flexible layouts, but should also provide
several alternative layouts to target different screen configurations. You do
-so by using <a href="http://developer.android.com/guide/practices/screens_support.html#qualifiers">configuration qualifiers</a>, which allows the runtime
+so by using <a href="http://developer.android.com/guide/practices/screens_support.html#qualifiers">configuration qualifiers</a>, which allows the runtime
to automatically select the appropriate resource based on the current device’s
configuration (such as a different layout design for different screen sizes).</p>
@@ -209,13 +209,13 @@
<p>However, this won't work well on pre-3.2 devices, because they don't
recognize <code>sw600dp</code> as a size qualifier, so you still have to use the <code>large</code>
-qualifier as well. So, you should have a file named
+qualifier as well. So, you should have a file named
<code>res/layout-large/main.xml</code>
which is identical to <code>res/layout-sw600dp/main.xml</code>. In the next section
you'll see a technique that allows you to avoid duplicating the layout files this way.</p>
-<h2 id="TaskUseAliasFilters">Use Layout Aliases</h2>
+<h2 id="TaskUseAliasFilters">Use Layout Aliases</h2>
<p>The smallest-width qualifier is available only on Android 3.2 and above.
Therefore, you should also still use the abstract size bins (small, normal,
@@ -271,7 +271,7 @@
{@code large}, and post-3.2 will match <code>sw600dp</code>).</p>
-<h2 id="TaskUseOriQuali">Use Orientation Qualifiers</h2>
+<h2 id="TaskUseOriQuali">Use Orientation Qualifiers</h2>
<p>Some layouts work well in both landscape and portrait orientations, but most of them can
benefit from adjustments. In the News Reader sample app, here is how the layout
@@ -287,7 +287,7 @@
<li><b>TV, landscape:</b> dual pane, wide, with action bar</li>
</ul></p>
-<p>So each of these layouts is defined in an XML file in the
+<p>So each of these layouts is defined in an XML file in the
<code>res/layout/</code> directory. To then assign each layout to the various screen
configurations, the app uses layout aliases to match them to
each configuration:</p>
@@ -361,7 +361,7 @@
the right and bottom borders indicate where the content should be
placed.</p>
-<p>Also, notice the <code>.9.png</code> extension. You must use this
+<p>Also, notice the <code>.9.png</code> extension. You must use this
extension, since this is how the framework detects that this is a nine-patch
image, as opposed to a regular PNG image.</p>
diff --git a/docs/html/training/notify-user/build-notification.jd b/docs/html/training/notify-user/build-notification.jd
index d24a496..2f96a20 100644
--- a/docs/html/training/notify-user/build-notification.jd
+++ b/docs/html/training/notify-user/build-notification.jd
@@ -42,9 +42,9 @@
<p>This lesson explains how to create and issue a notification.</p>
-<p>The examples in this class are based on the
-{@link android.support.v4.app.NotificationCompat.Builder} class.
-{@link android.support.v4.app.NotificationCompat.Builder}
+<p>The examples in this class are based on the
+{@link android.support.v4.app.NotificationCompat.Builder} class.
+{@link android.support.v4.app.NotificationCompat.Builder}
is in the <a href="{@docRoot}">Support Library</a>. You should use
{@link android.support.v4.app.NotificationCompat} and its subclasses,
particularly {@link android.support.v4.app.NotificationCompat.Builder}, to
@@ -52,9 +52,9 @@
<h2 id="builder">Create a Notification Builder</h2>
-<p>When creating a notification, specify the UI content and actions with a
-{@link android.support.v4.app.NotificationCompat.Builder} object. At bare minimum,
-a {@link android.support.v4.app.NotificationCompat.Builder Builder}
+<p>When creating a notification, specify the UI content and actions with a
+{@link android.support.v4.app.NotificationCompat.Builder} object. At bare minimum,
+a {@link android.support.v4.app.NotificationCompat.Builder Builder}
object must include the following:</p>
<ul>
@@ -96,7 +96,7 @@
android.app.Activity} from a notification, you must preserve the user's expected
navigation experience. In the snippet below, clicking the notification opens a
new activity that effectively extends the behavior of the notification. In this
-case there is no need to create an artificial back stack (see
+case there is no need to create an artificial back stack (see
<a href="navigation.html">Preserving Navigation when Starting an Activity</a> for
more information):</p>
@@ -132,11 +132,11 @@
<p>To issue the notification:</p>
<ul>
-<li>Get an instance of {@link android.app.NotificationManager}.</li>
+<li>Get an instance of {@link android.app.NotificationManager}.</li>
<li>Use the {@link android.app.NotificationManager#notify notify()} method to issue the
-notification. When you call {@link android.app.NotificationManager#notify notify()}, specify a notification ID.
-You can use this ID to update the notification later on. This is described in more detail in
+notification. When you call {@link android.app.NotificationManager#notify notify()}, specify a notification ID.
+You can use this ID to update the notification later on. This is described in more detail in
<a href="managing.html">Managing Notifications</a>.</li>
<li>Call {@link
@@ -152,7 +152,7 @@
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
-NotificationManager mNotifyMgr =
+NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
diff --git a/docs/html/training/notify-user/display-progress.jd b/docs/html/training/notify-user/display-progress.jd
index 3439571..e2cf033 100644
--- a/docs/html/training/notify-user/display-progress.jd
+++ b/docs/html/training/notify-user/display-progress.jd
@@ -59,9 +59,9 @@
<h2 id="FixedProgress">Display a Fixed-duration Progress Indicator</h2>
<p>
To display a determinate progress bar, add the bar to your notification by calling
- {@link android.support.v4.app.NotificationCompat.Builder#setProgress
- setProgress(max, progress, false)} and then issue the notification.
- The third argument is a boolean that indicates whether the
+ {@link android.support.v4.app.NotificationCompat.Builder#setProgress
+ setProgress(max, progress, false)} and then issue the notification.
+ The third argument is a boolean that indicates whether the
progress bar is indeterminate (<strong>true</strong>) or determinate (<strong>false</strong>).
As your operation proceeds,
increment <code>progress</code>, and update the notification. At the end of the operation,
@@ -74,7 +74,7 @@
You can either leave the progress bar showing when the operation is done, or remove it. In
either case, remember to update the notification text to show that the operation is complete.
To remove the progress bar, call
- {@link android.support.v4.app.NotificationCompat.Builder#setProgress
+ {@link android.support.v4.app.NotificationCompat.Builder#setProgress
setProgress(0, 0, false)}. For example:
</p>
<pre>
@@ -136,14 +136,14 @@
<p>
To display a continuing (indeterminate) activity indicator, add it to your notification with
{@link android.support.v4.app.NotificationCompat.Builder#setProgress setProgress(0, 0, true)}
- and issue the notification. The first two arguments are ignored, and the third argument
+ and issue the notification. The first two arguments are ignored, and the third argument
declares that the indicator is indeterminate. The result is an indicator
that has the same style as a progress bar, except that its animation is ongoing.
</p>
<p>
Issue the notification at the beginning of the operation. The animation will run until you
modify your notification. When the operation is done, call
- {@link android.support.v4.app.NotificationCompat.Builder#setProgress
+ {@link android.support.v4.app.NotificationCompat.Builder#setProgress
setProgress(0, 0, false)} and then update the notification to remove the activity indicator.
Always do this; otherwise, the animation will run even when the operation is complete. Also
remember to change the notification text to indicate that the operation is complete.
@@ -160,7 +160,7 @@
</pre>
<p>
Replace the lines you've found with the following lines. Notice that the third parameter
- in the {@link android.support.v4.app.NotificationCompat.Builder#setProgress setProgress()}
+ in the {@link android.support.v4.app.NotificationCompat.Builder#setProgress setProgress()}
call is set to {@code true} to indicate that the progress bar is
indeterminate:
</p>
diff --git a/docs/html/training/notify-user/expanded.jd b/docs/html/training/notify-user/expanded.jd
index b657426..23d85d4 100644
--- a/docs/html/training/notify-user/expanded.jd
+++ b/docs/html/training/notify-user/expanded.jd
@@ -75,7 +75,7 @@
</ul>
<p>The normal view provides these features through a new activity that launches
-when the user clicks the notification. Keep this in mind as you design your notifications—first
+when the user clicks the notification. Keep this in mind as you design your notifications—first
provide the functionality in the normal view, since
this is how many users will interact with the notification.</p>
@@ -87,19 +87,19 @@
<p>In this snippet, the
{@link android.app.IntentService} method
-{@link android.app.IntentService#onHandleIntent onHandleIntent()} specifies the new activity
+{@link android.app.IntentService#onHandleIntent onHandleIntent()} specifies the new activity
that will be launched if the user
-clicks the notification itself. The method
-{@link android.support.v4.app.NotificationCompat.Builder#setContentIntent setContentIntent()}
+clicks the notification itself. The method
+{@link android.support.v4.app.NotificationCompat.Builder#setContentIntent setContentIntent()}
defines a pending intent that should be fired when the user
clicks the notification, thereby launching the activity.</p>
<pre>Intent resultIntent = new Intent(this, ResultActivity.class);
resultIntent.putExtra(CommonConstants.EXTRA_MESSAGE, msg);
-resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
-
-// Because clicking the notification launches a new ("special") activity,
+
+// Because clicking the notification launches a new ("special") activity,
// there's no need to create an artificial back stack.
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
@@ -130,8 +130,8 @@
PendingIntent piSnooze = PendingIntent.getService(this, 0, snoozeIntent, 0);
</pre>
-<p>This snippet shows how to construct the
-{@link android.support.v4.app.NotificationCompat.Builder Builder} object.
+<p>This snippet shows how to construct the
+{@link android.support.v4.app.NotificationCompat.Builder Builder} object.
It sets the style for the big
view to be "big text," and sets its content to be the reminder message. It uses
{@link android.support.v4.app.NotificationCompat.Builder#addAction addAction()}
diff --git a/docs/html/training/notify-user/index.jd b/docs/html/training/notify-user/index.jd
index 616e767..57efd65 100644
--- a/docs/html/training/notify-user/index.jd
+++ b/docs/html/training/notify-user/index.jd
@@ -43,9 +43,9 @@
</div>
<p>
- A notification is a user interface element that you display outside your app's normal UI to indicate
- that an event has occurred. Users can choose to view the notification while using other apps and respond
- to it when it's convenient for them.
+ A notification is a user interface element that you display outside your app's normal UI to indicate
+ that an event has occurred. Users can choose to view the notification while using other apps and respond
+ to it when it's convenient for them.
</p>
@@ -86,10 +86,10 @@
</strong>
</dt>
<dd>
- Learn how to create a big view within an expanded notification, while still maintaining
+ Learn how to create a big view within an expanded notification, while still maintaining
backward compatibility.
</dd>
-
+
<dt>
<strong>
<a href="display-progress.html">Displaying Progress in a Notification</a>
diff --git a/docs/html/training/notify-user/navigation.jd b/docs/html/training/notify-user/navigation.jd
index b7051ab..cdb7f3d 100644
--- a/docs/html/training/notify-user/navigation.jd
+++ b/docs/html/training/notify-user/navigation.jd
@@ -37,7 +37,7 @@
</div>
</div>
<p>
- Part of designing a notification is preserving the user's expected navigation experience.
+ Part of designing a notification is preserving the user's expected navigation experience.
For a detailed discussion of this topic, see the
<a href="{@docRoot}guide/topics/ui/notifiers/notifications.html#NotificationResponse">Notifications</a>
API guide.
@@ -49,7 +49,7 @@
</dt>
<dd>
You're starting an {@link android.app.Activity} that's part of the application's normal
- workflow.
+ workflow.
</dd>
<dt>
Special activity
@@ -202,7 +202,7 @@
Intent notifyIntent =
new Intent(new ComponentName(this, ResultActivity.class));
// Sets the Activity to start in a new, empty task
-notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
// Creates the PendingIntent
PendingIntent notifyIntent =
diff --git a/docs/html/training/run-background-service/report-status.jd b/docs/html/training/run-background-service/report-status.jd
index 41121c1..41fbb00 100644
--- a/docs/html/training/run-background-service/report-status.jd
+++ b/docs/html/training/run-background-service/report-status.jd
@@ -91,7 +91,7 @@
</p>
<h2 id="ReceiveStatus">Receive Status Broadcasts from an IntentService</h2>
<p>
-
+
To receive broadcast {@link android.content.Intent} objects, use a subclass of
{@link android.content.BroadcastReceiver}. In the subclass, implement the
{@link android.content.BroadcastReceiver#onReceive BroadcastReceiver.onReceive()} callback
@@ -137,7 +137,7 @@
// The filter's action is BROADCAST_ACTION
IntentFilter mStatusIntentFilter = new IntentFilter(
Constants.BROADCAST_ACTION);
-
+
// Adds a data filter for the HTTP scheme
mStatusIntentFilter.addDataScheme("http");
...
@@ -194,6 +194,6 @@
{@link android.content.Intent}.
</p>
<p>
-
+
</p>
diff --git a/docs/html/training/sign-in/index.jd b/docs/html/training/sign-in/index.jd
index d7c8e1d..a585944 100644
--- a/docs/html/training/sign-in/index.jd
+++ b/docs/html/training/sign-in/index.jd
@@ -11,8 +11,8 @@
alt="Google maps sample image">
<p>
- Google Sign-In for Android lets you authenticate a user with the same credentials they use on
- Google. After a user signs in with Google, you can create more engaging experiences and drive
+ Google Sign-In for Android lets you authenticate a user with the same credentials they use on
+ Google. After a user signs in with Google, you can create more engaging experiences and drive
usage of your app.
</p>
@@ -34,8 +34,8 @@
<h4>Access the profile and social graph</h4>
<p>
- After users have signed in with Google, your app can welcome them by name and display their
- picture. If your app requests social scopes, it can connect users with friends, and access
+ After users have signed in with Google, your app can welcome them by name and display their
+ picture. If your app requests social scopes, it can connect users with friends, and access
age range, language, and public profile information.<br>
<a href="https://developers.google.com/identity/sign-in/android/people" class="external-link">
Getting Profile Information</a>.
@@ -47,6 +47,6 @@
The Google Android APIs are part of the Google Play services platform. To use Google features,
set up the Google Play services SDK in your app development project. For more information, see
the <a class="external-link" href=
- "https://developers.google.com/identity/sign-in/android/start-integrating">Start Integrating</a>
+ "https://developers.google.com/identity/sign-in/android/start-integrating">Start Integrating</a>
guide for Google Sign-In.
</p>
\ No newline at end of file