blob: 30d807ff9300967248e26af441be8e35cc09796f [file] [log] [blame]
Robert Ly8db858f2011-10-18 13:30:47 -07001page.title=Support Package
Scott Main28fb09e2011-05-23 17:27:17 -07002
3@jd:body
4
5<div id="qv-wrapper">
6<div id="qv">
Joe Fernandez71d5c1d2011-12-15 22:33:41 -08007
Scott Main28fb09e2011-05-23 17:27:17 -07008<h2>In this document</h2>
9<ol>
10 <li><a href="#Notes">Revisions</a></li>
Robert Ly8db858f2011-10-18 13:30:47 -070011 <li><a href="#Downloading">Downloading the Support Package</a></li>
Scott Mainaecaf932011-07-14 10:01:42 -070012 <li><a href="#SettingUp">Setting Up a Project to Use a Library</a></li>
13 <li><a href="#Using">Using the v4 Library APIs</a></li>
14 <li><a href="#Docs">Reference Docs</a></li>
Scott Main28fb09e2011-05-23 17:27:17 -070015 <li><a href="#Samples">Samples</a></li>
16</ol>
17
18<h2>See also</h2>
19<ol>
20 <li><a
21href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for Android 3.0</a></li>
22 <li><a href="http://code.google.com/p/iosched/">Google I/O App source code</a></li>
23</ol>
24
25</div>
26</div>
27
28<p><em>Minimum API level supported:</em> <b>4</b></p>
29
Robert Ly8db858f2011-10-18 13:30:47 -070030<p>The Support Package includes static "support libraries" that you can add to your Android
Scott Mainaecaf932011-07-14 10:01:42 -070031application in order to use APIs that are either not available for older platform versions or that
32offer "utility" APIs that aren't a part of the framework APIs. The goal is to simplify your
Scott Mainffcbe482011-07-15 09:50:49 -070033development by offering more APIs that you can bundle with your application so you can
Scott Mainaecaf932011-07-14 10:01:42 -070034worry less about platform versions.</p>
Scott Main28fb09e2011-05-23 17:27:17 -070035
Robert Ly8db858f2011-10-18 13:30:47 -070036<p class="note"><strong>Note:</strong> The Support Package includes more than one support
Scott Mainffcbe482011-07-15 09:50:49 -070037library. Each one has a different <em>minimum API level</em>. For example, one library requires API
Joe Fernandez71d5c1d2011-12-15 22:33:41 -080038level 4 or higher, while another requires API level 13 or higher (v13 is a superset of v4 and
39includes additional
Robert Ly8db858f2011-10-18 13:30:47 -070040support classes to work with v13 APIs). The minimum version is indicated
Scott Mainffcbe482011-07-15 09:50:49 -070041by the directory name, such as {@code v4/} and {@code v13/}.</p>
Scott Main28fb09e2011-05-23 17:27:17 -070042
43
44<h2 id="Notes">Revisions</h2>
45
46<p>The sections below provide notes about successive releases of
Robert Ly8db858f2011-10-18 13:30:47 -070047the Support Package, as denoted by revision number.</p>
48
Scott Main28fb09e2011-05-23 17:27:17 -070049<div class="toggle-content open">
50
51 <p><a href="#" onclick="return toggleContent(this)">
52 <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img" />
Joe Fernandezdad557e2012-03-16 01:17:58 -070053 Support Package, revision 7 (March 2012)
54 </a></p>
55
56 <div class="toggle-content-toggleme" style="padding-left:2em">
57 <dl>
58 <dt>Changes for v4 support library:</dt>
59 <dd>
60 <ul>
61 <li>Added {@link android.support.v4.app.ShareCompat}, which provides helper classes
62for sending and receiving content for social sharing applications, including new metadata for
63attributing shared data to the source app. This class also provides compatible integration with the
64new {@link android.widget.ShareActionProvider} in Android 4.0.</li>
65 <li>Added {@link android.support.v4.app.NavUtils} and {@link
66android.support.v4.app.TaskStackBuilder} to provide support for implementing the
67<a href="{@docRoot}design/index.html">Android Design</a> guidelines for navigation. These
68additions include a way to implement the action bar's <em>Up</em> button across versions.
69For an example implementation of this pattern, see the AppNavigation sample in
70({@code <em>&lt;sdk&gt;</em>/samples/<em>&lt;platform&gt;</em>/AppNavigation}).</li>
71 <li>Added {@link android.support.v4.app.NotificationCompat.Builder} to provide a
72compatibility implementation of Android 3.0's {@link android.app.Notification.Builder} helper class
73for creating standardized system notifications.</li>
74 </ul>
75 </dd>
76 </dl>
77 </div>
78
79<div class="toggle-content closed">
80
81 <p><a href="#" onclick="return toggleContent(this)">
82 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
Joe Fernandeze4f20312011-12-15 13:23:53 -080083 Support Package, revision 6 (December 2011)
84 </a></p>
85
86 <div class="toggle-content-toggleme" style="padding-left:2em">
Joe Fernandez71d5c1d2011-12-15 22:33:41 -080087 <p class="note"><strong>Note:</strong> Reference for support library APIs are now available with
88 the framework references, for example: {@link android.support.v4.app}.</p>
89<dl>
Joe Fernandeze4f20312011-12-15 13:23:53 -080090 <dt>Changes for v4 support library:</dt>
91 <dd>
92 <ul>
93 <li>Changes to ViewPager:
94 <ul>
95 <li>Added extra decorative view support for {@link android.support.v4.view.ViewPager}.
96 Decorative views may be supplied as child views of a pager in XML layout.</li>
97 <li>Added {@link android.support.v4.view.PagerAdapter#getPageTitle
98 PagerAdapter.getPageTitle()} to supply title strings for pages, which defaults to no
99 title for each page.</li>
100 <li>Added {@link android.support.v4.view.PagerTitleStrip}, a non-interactive title
101 strip, that can be added as a child of ViewPager. Developers can supply text
102 appearance and color, as well as layout sizing and gravity information.</li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800103 <li>Updated {@link android.support.v4.view.PagerAdapter} methods to take ViewGroup
104 objects, rather than View to avoid class casting in adapter implementations.</li>
105 <li>Updated {@link android.support.v4.view.ViewPager} to use Launcher-style
106 fling behavior.</li>
Joe Fernandeze4f20312011-12-15 13:23:53 -0800107 <li>Bug fixes for user interface interaction and test automation.</li>
108 </ul>
109 </li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800110
Joe Fernandeze4f20312011-12-15 13:23:53 -0800111 <li>Support for Fragments:
112 <ul>
113 <li>Changed {@code setStartDeferred()} method to {@link
114 android.support.v4.app.Fragment#setUserVisibleHint}.</li>
115 <li>Added deferred start for off-screen pages to improve performance.</li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800116 </ul>
Joe Fernandeze4f20312011-12-15 13:23:53 -0800117 </li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800118
Joe Fernandeze4f20312011-12-15 13:23:53 -0800119 <li>Support for Accessiblity APIs:
120 <ul>
121 <li>Updated {@link android.support.v4.view.AccessibilityDelegateCompat} methods
122 to return empty lists instead of null.</li>
123 <li>Added new APIs needed by the v4 samples.</li>
124 </ul>
125 </li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800126
Joe Fernandeze4f20312011-12-15 13:23:53 -0800127 </ul>
128 </dd>
129 </dl>
130 </div>
131
132<div class="toggle-content closed">
133
134 <p><a href="#" onclick="return toggleContent(this)">
135 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
136 Support Package, revision 5 (December 2011)
Robert Ly8db858f2011-10-18 13:30:47 -0700137 </a></p>
138
139 <div class="toggle-content-toggleme" style="padding-left:2em">
140 <dl>
141 <dt>Changes for v4 support library:</dt>
142 <dd>
143 <ul>
144 <li>Support for Accessiblity APIs:
145 <ul>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800146 <li>Added {@link android.support.v4.view.AccessibilityDelegateCompat}
147 to support {@link android.view.View.AccessibilityDelegate}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700148
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800149 <li>Added {@link android.support.v4.view.accessibility.AccessibilityEventCompat}
150 to support {@link android.view.accessibility.AccessibilityEvent}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700151
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800152 <li>Added {@link android.support.v4.view.accessibility.AccessibilityManagerCompat}
153 to support {@link android.view.accessibility.AccessibilityManager}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700154
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800155 <li>Added {@link android.support.v4.view.accessibility.AccessibilityNodeInfoCompat}
156 to support {@link android.view.accessibility.AccessibilityNodeInfo}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700157
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800158 <li>Added {@link android.support.v4.view.accessibility.AccessibilityRecordCompat}
159 to support {@link android.view.accessibility.AccessibilityRecord}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700160
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800161 <li>Added {@link
162 android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat}
163 to support {@link android.accessibilityservice.AccessibilityServiceInfo}.</li>
Robert Ly8db858f2011-10-18 13:30:47 -0700164
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800165 <li>Added {@link android.support.v4.view.ViewGroupCompat}
Robert Ly8db858f2011-10-18 13:30:47 -0700166 to support accessibility features in {@link android.view.ViewGroup}.
167 </li>
168
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800169 <li>Modified {@link android.support.v4.view.ViewCompat}
Robert Ly8db858f2011-10-18 13:30:47 -0700170 to support accessibility features in {@link android.view.View}.</li>
171 </ul>
172 </li>
173
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800174 <li>Changes to ViewPager:
Joe Fernandeze4f20312011-12-15 13:23:53 -0800175 <ul>
176 <li>Added support for margins between pages.
177 An optional {@link android.graphics.drawable.Drawable} can be provided
178 to fill the margins.</li>
179 <li>Added support for {@link android.widget.EdgeEffect}.</li>
180 <li>Added support for keyboard navigation</li>
181 <li>Added support to control how many pages are kept to either side
182 of the current page.</li>
183 <li>Improved touch physics.</li>
184 <li>Bug fixes for user interface behavior.</li>
185 </ul>
186 </li>
187 </ul>
188 </dd>
189 </dl>
190 </div>
191
192<div class="toggle-content closed">
193
194 <p><a href="#" onclick="return toggleContent(this)">
195 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
196 Support Package, revision 4 (October 2011)
197 </a></p>
198
199 <div class="toggle-content-toggleme" style="padding-left:2em">
200 <dl>
201 <dt>Changes for v4 support library:</dt>
202 <dd>
203 <ul>
Robert Ly8db858f2011-10-18 13:30:47 -0700204 <li>Added <code>EdgeEffectCompat</code> to
205 support {@link android.widget.EdgeEffect}.</li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800206
Robert Ly8db858f2011-10-18 13:30:47 -0700207 <li>Added <code>LocalBroadcastManager</code> to allow applications to easily
208 register for and receive intents within a single application without
209 broadcasting them globally.</li>
210
211 <li>Added support in <code>ViewCompat</code> to check for and set overscroll
212 modes for {@link android.view.View}s on Android 2.3 and later.</li>
213 <li>Changes to Fragment APIs:
214 <ul>
215 <li>Added new APIs to control the visibility of new menus.</li>
216 <li>Added custom animation APIs.</li>
217 <li>Added APIs in <code>FragmentActivity</code> to retain custom,
218 non-configuration instance data.</li>
219 <li>Various bug fixes.</li>
220 </ul>
221 </li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800222
Robert Ly8db858f2011-10-18 13:30:47 -0700223 <li>Fixed a {@link android.content.Loader} bug that caused issues in
224 canceling {@link android.os.AsyncTask}s when running on Froyo and older
225 versions of the platform. The support
226 code now uses its own version of {@link android.os.AsyncTask} to keep the same
227 behavior on all platform versions.</li>
228
229 </ul>
230 </dd>
231 </dl>
232 </div>
233
234
235
236</div>
237
238
239<div class="toggle-content closed">
240
241 <p><a href="#" onclick="return toggleContent(this)">
242 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
Scott Mainaecaf932011-07-14 10:01:42 -0700243 Compatibility Package, revision 3 (July 2011)
Scott Main28fb09e2011-05-23 17:27:17 -0700244 </a></p>
245
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800246 <div class="toggle-content-toggleme" style="padding-left:2em">
Scott Main28fb09e2011-05-23 17:27:17 -0700247 <dl>
Scott Mainaecaf932011-07-14 10:01:42 -0700248 <dt>Changes for v4 support library:</dt>
249 <dd>
250 <ul>
251 <li>Adds support for {@link android.app.Fragment.SavedState}</li>
252 <li>Adds {@code MotionEventCompat} to support newer {@link
253android.view.MotionEvent} APIs</li>
254 <li>Adds {@code VelocityTrackerCompat} to support a newer {@link
255android.view.VelocityTracker} APIs</li>
256 <li>Adds {@code ViewConfigurationCompat} to support a newer {@link
257android.view.ViewConfiguration} APIs</li>
258 <li>All new APIs (available only in the support library) that allow you to create UIs
Scott Mainffcbe482011-07-15 09:50:49 -0700259with horizontal paging, allowing users to swipe left and right between content views. Classes to
260support this include:
Scott Mainaecaf932011-07-14 10:01:42 -0700261 <ul>
262 <li>{@code ViewPager}: A {@link android.view.ViewGroup} that manages the
263layout for the child views, which the user can swipe between.</li>
264 <li>{@code PagerAdapter}: An adapter that populates the {@code ViewPager} with the
265views that represent each page.</li>
266 <li>{@code FragmentPagerAdapter}: An extension of {@code PagerAdapter} for flipping
267between fragments.</li>
Scott Mainffcbe482011-07-15 09:50:49 -0700268 <li>{@code FragmentStatePagerAdapter}: An extension of {@code PagerAdapter} for
269flipping between fragments that uses the library's support for {@link
270android.app.Fragment.SavedState}.</li>
Scott Mainaecaf932011-07-14 10:01:42 -0700271 </ul>
272 </li>
273 </ul>
274 </dd>
275 <dt>New v13 support library:</dt>
276 <dd>
277 <ul>
278 <li>Includes the {@code FragmentPagerAdapter} and {@code FragmentStatePagerAdapter}
279to support the horizontal paging.
280 <p>These are exactly the same as the APIs added to the v4 support library, but rely on
281other platform components in Android 3.2. Use this library instead of v4 if you're developing for
282Android 3.2 and higher (all other APIs in the v4 library are already available with API level
28313).</p>
284 </li>
285 </ul>
286 </dd>
287 </dl>
288 </div>
289
290</div>
291
292
293<div class="toggle-content closed">
294
295 <p><a href="#" onclick="return toggleContent(this)">
296 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
297 Compatibility Package, revision 2 (May 2011)
298 </a></p>
299
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800300 <div class="toggle-content-toggleme" style="padding-left:2em">
Scott Mainaecaf932011-07-14 10:01:42 -0700301 <dl>
302 <dt>Changes for v4 library:</dt>
Scott Main28fb09e2011-05-23 17:27:17 -0700303 <dd>
304 <ul>
Scott Mainaecaf932011-07-14 10:01:42 -0700305 <li>Support for fragment animations</li>
Joe Fernandeze4f20312011-12-15 13:23:53 -0800306 <li>Fix {@code android.support.v4.app.Fragment#onActivityResult Fragment.onActivityResult()}
307 bug</li>
Scott Main28fb09e2011-05-23 17:27:17 -0700308 </ul>
309 </dd>
310 </dl>
311 </div>
312
313</div>
314
315
316<div class="toggle-content closed">
317
318 <p><a href="#" onclick="return toggleContent(this)">
319 <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" />
Scott Mainaecaf932011-07-14 10:01:42 -0700320 Compatibility Package, revision 1 (March 2011)
Scott Main28fb09e2011-05-23 17:27:17 -0700321 </a></p>
322
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800323 <div class="toggle-content-toggleme" style="padding-left:2em">
Scott Mainaecaf932011-07-14 10:01:42 -0700324 <p>Initial release with the v4 library.</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700325 </div>
326
327</div>
328
329
330
Robert Ly8db858f2011-10-18 13:30:47 -0700331<h2 id="Downloading">Downloading the Support Package</h2>
Scott Main28fb09e2011-05-23 17:27:17 -0700332
Robert Ly8db858f2011-10-18 13:30:47 -0700333<p>The Support Package is provided as a downloadable package from the Android SDK and AVD
Scott Mainaecaf932011-07-14 10:01:42 -0700334Manager. To install:</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700335
336<ol>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800337 <li>Launch the SDK and AVD Manager.
Scott Main28fb09e2011-05-23 17:27:17 -0700338 <p>From Eclipse, you can select <strong>Window</strong>
339&gt; <strong>Android SDK and AVD Manager</strong>. Or, launch {@code SDK Manager.exe} from
340the {@code &lt;sdk&gt;/} directory (on Windows only) or {@code android} from the {@code
341&lt;sdk&gt;/tools/} directory.</p></li>
Robert Ly8db858f2011-10-18 13:30:47 -0700342 <li>Expand the Android Repository, check <strong>Android Support package</strong>
Scott Main28fb09e2011-05-23 17:27:17 -0700343and click <strong>Install selected</strong>.</li>
344 <li>Proceed to install the package.</li>
345</ol>
346
Scott Mainaecaf932011-07-14 10:01:42 -0700347<p>When done, all files (including source code, samples, and the {@code .jar} files) are saved
Robert Ly8db858f2011-10-18 13:30:47 -0700348into the <code>&lt;sdk&gt;/extras/android/support/</code> directory. This directory contains
Scott Mainaecaf932011-07-14 10:01:42 -0700349each of the different support libraries, such as the library for API level 4 and up and the library
350for API level 13 and up, each named with the respective version (such as {@code v4/}).</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700351
352
Scott Mainaecaf932011-07-14 10:01:42 -0700353<h2 id="SettingUp">Setting Up a Project to Use a Library</h2>
Scott Main28fb09e2011-05-23 17:27:17 -0700354
Scott Mainaecaf932011-07-14 10:01:42 -0700355<p>To add one of the libraries to your Android project:</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700356<ol>
357 <li>In your Android project, create a directory named {@code libs} at the root of your
358project (next to {@code src/}, {@code res/}, etc.)</li>
Scott Mainaecaf932011-07-14 10:01:42 -0700359 <li>Locate the JAR file for the library you want to use and copy it into the {@code
360libs/} directory.
361 <p>For example, the library that supports API level 4 and up is located at {@code
Robert Ly8db858f2011-10-18 13:30:47 -0700362&lt;sdk&gt;/extras/android/support/v4/android-support-v4.jar}.</p>
Scott Mainaecaf932011-07-14 10:01:42 -0700363 </li>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800364 <li>Add the JAR to your project build path.
Scott Mainaecaf932011-07-14 10:01:42 -0700365 <p>In Eclipse, right-click the JAR file in the Package Explorer, select <strong>Build
Joe Fernandeze4f20312011-12-15 13:23:53 -0800366Path</strong> &gt; <strong>Add to Build Path</strong>.</p>
Scott Mainaecaf932011-07-14 10:01:42 -0700367 </li>
Scott Main28fb09e2011-05-23 17:27:17 -0700368</ol>
369
Scott Mainaecaf932011-07-14 10:01:42 -0700370<p>Your application is now ready to use the library APIs. All the
371provided APIs are available in the {@code android.support} package (for
372example, {@code android.support.v4}).</p>
373
374<p class="note"><strong>Tip:</strong> To see the library APIs in action, take a look at the sample
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800375apps in {@code &lt;sdk&gt;/extras/android/support/&lt;version&gt;/samples/}.</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700376
377<p class="warning"><strong>Warning:</strong> Be certain that you not confuse the standard
Scott Mainaecaf932011-07-14 10:01:42 -0700378{@code android} packages with those in {@code android.support} library. Some code completion tools
379might
Scott Main28fb09e2011-05-23 17:27:17 -0700380get this wrong, especially if you're building against recent versions of the platform. To be safe,
381keep your build target set to the same version as you have defined for your <a
382href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
Scott Mainaecaf932011-07-14 10:01:42 -0700383and double check the import statements for classes that also exist in the support library, such as
384{@code SimpleCursorAdapter}.</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700385
386
Scott Mainaecaf932011-07-14 10:01:42 -0700387<h2 id="Using">Using the v4 Library APIs</h2>
Scott Main28fb09e2011-05-23 17:27:17 -0700388
Scott Mainaecaf932011-07-14 10:01:42 -0700389<p>The support library for v4 provides access to several classes introduced with Android 3.0 and
390beyond, plus some updated version of existing classes, and even some APIs that currently don't
391exist in the Android platform. Some of the most useful and notable classes that have
392counterparts in the v4 support library are:</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700393
394<ul>
395 <li>{@link android.app.Fragment}</li>
396 <li>{@link android.app.FragmentManager}</li>
397 <li>{@link android.app.FragmentTransaction}</li>
398 <li>{@link android.app.ListFragment}</li>
399 <li>{@link android.app.DialogFragment}</li>
400 <li>{@link android.app.LoaderManager}</li>
401 <li>{@link android.content.Loader}</li>
402 <li>{@link android.content.AsyncTaskLoader}</li>
403 <li>{@link android.content.CursorLoader}</li>
404</ul>
405
406<p>For each of the classes above (and others not listed), the APIs work almost exactly the same
Scott Mainaecaf932011-07-14 10:01:42 -0700407as the counterparts in the latest Android platform. Thus, you can usually refer to
408the online documentation for information about the supported APIs. There are some
Scott Main28fb09e2011-05-23 17:27:17 -0700409differences, however. Most notably:</p>
410
411<ul>
412 <li>When creating an activity to use fragments, you must declare your activity to extend the
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800413{@link android.support.v4.app.FragmentActivity} class (instead of the traditional
414{@link android.app.Activity} class).</li>
415 <li>To manage your fragments and loaders, you must use the methods
416 {@link android.support.v4.app.FragmentActivity#getSupportFragmentManager
417 FragmentActivity.getSupportFragmentManager()} and
418 {@link android.support.v4.app.FragmentActivity#getSupportLoaderManager
419 FragmentActivity.getSupportLoaderManager()} (instead of the
420 {@link android.app.Activity#getFragmentManager()} and
421 {@link android.app.Activity#getLoaderManager()} methods).</li>
Scott Main28fb09e2011-05-23 17:27:17 -0700422 <li>The {@link android.app.ActionBar} is <strong>not supported</strong> by the library.
423However, when creating your <a href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options
424Menu</a>, you can declare which items should be added to the Action Bar when it's available (on
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800425Android 3.0 or later). You can do so with the
426{@link android.support.v4.view.MenuCompat#setShowAsAction MenuCompat.setShowAsAction()} method, for
Scott Main28fb09e2011-05-23 17:27:17 -0700427example:
428<pre>
429public boolean onCreateOptionsMenu(Menu menu) {
430 MenuInflater inflater = getMenuInflater();
431 inflater.inflate(R.menu.options, menu);
432 MenuCompat.setShowAsAction(menu.findItem(R.id.action_search), 1);
433 return true;
434}
435</pre>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800436<p>Also see the <a href="{@docRoot}resources/samples/ActionBarCompat/index.html">Action Bar
437Compatibility</a> sample for a demonstration of how to use {@link android.app.ActionBar} on Android
4383.0+ and also support action bar functionality on older versions.</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700439</li>
440</ul>
441
Scott Main28fb09e2011-05-23 17:27:17 -0700442<div class="note"><p><strong>Tip:</strong> To enable the Holographic theme on devices
443running Android 3.0 or higher, declare in your manifest file that your application targets
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800444API level 11, for example:</p>
Scott Main28fb09e2011-05-23 17:27:17 -0700445<pre>
446&lt;uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" /&gt;
447</pre>
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800448<p>This way, your application automatically receives the Holographic theme and the Action Bar for
Scott Main28fb09e2011-05-23 17:27:17 -0700449each activity when running on Android 3.0 and higher.</p>
450</div>
451
452<p>For more information about how you can optimize your application for the latest
453Android-powered devices, read <a href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing
454Apps for Android 3.0</a>.</p>
455
456
Scott Mainaecaf932011-07-14 10:01:42 -0700457<h2 id="Docs">Reference Docs</h2>
458
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800459<p>The reference documentation for the Support Packages is included as part of the Android
460online developer documentation:</p>
Scott Mainaecaf932011-07-14 10:01:42 -0700461
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800462<ul>
463 <li><a href="{@docRoot}reference/android/support/v4/app/package-summary.html">Support Package
464 API 4 Reference</a></li>
465 <li><a href="{@docRoot}reference/android/support/v13/app/package-summary.html">Support Package
466 API 13 Reference</a></li>
467</ul>
Scott Mainaecaf932011-07-14 10:01:42 -0700468
469
Scott Main28fb09e2011-05-23 17:27:17 -0700470<h2 id="Samples">Samples</h2>
471
Scott Mainaecaf932011-07-14 10:01:42 -0700472<p>If you want to see some code that uses the support libraries, samples are included with the
Joe Fernandez71d5c1d2011-12-15 22:33:41 -0800473Support Package, inside each support library directory, for example; {@code
474&lt;sdk&gt;/extras/android/support/v4/samples/}. You can also view these samples as part of the
475Android online developer documentation:</p>
476
477<ul>
478 <li><a href="{@docRoot}resources/samples/Support4Demos/index.html">Support API 4 Demos</a></li>
479 <li><a href="{@docRoot}resources/samples/Support13Demos/index.html">Support API 13 Demos</a></li>
480</ul>
Scott Main28fb09e2011-05-23 17:27:17 -0700481
482<p>Additionally, the <a href="http://code.google.com/p/iosched/">Google I/O App</a> is a complete
Scott Mainaecaf932011-07-14 10:01:42 -0700483application that uses the v4 support library to provide a single APK for both handsets and tablets
484and also demonstrates some of Android's best practices in Android UI design.</p>