Skip to content

Commit abfe4cb

Browse files
scottamainAndroid (Google) Code Review
authored andcommitted
Merge "docs: further clarify the behavior of targetSdkVersion bug: 5854083" into ics-mr1
2 parents 4b1261f + d4eb682 commit abfe4cb

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

docs/html/guide/topics/manifest/uses-sdk-element.jd

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,40 @@ href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>.</p>
6060
attribute, the system assumes a default value of "1", which indicates that your
6161
application is compatible with all versions of Android. If your application is
6262
<em>not</em> compatible with all versions (for instance, it uses APIs introduced
63-
in API Level 3) and you have not declared the proper <code>android:minSdkVersion</code>,
63+
in API Level 3) and you have not declared the proper <code>minSdkVersion</code>,
6464
then when installed on a system with an API Level less than 3, the application
6565
will crash during runtime when attempting to access the unavailable APIs. For
6666
this reason, be certain to declare the appropriate API Level in the
6767
<code>minSdkVersion</code> attribute.</p>
6868
</dd>
6969

7070
<dt><a name="target"></a>{@code android:targetSdkVersion}</dt>
71-
<dd>An integer designating the API Level that the application is targetting.
72-
73-
<p>With this attribute set, the application says that it is able to run on
74-
older versions (down to {@code minSdkVersion}), but was explicitly tested to
75-
work with the version specified here. Specifying this target version allows the
76-
platform to disable compatibility settings that are not required for the target
77-
version (which may otherwise be turned on in order to maintain
78-
forward-compatibility) or enable newer features that are not available to older
79-
applications. This does not mean that you can program different features for
80-
different versions of the platform&mdash;it simply informs the platform that you
81-
have tested against the target version and the platform should not perform any
82-
extra work to maintain forward-compatibility with the target version.</p>
71+
<dd>An integer designating the API Level that the application targets. If not set, the default
72+
value equals that given to {@code minSdkVersion}.
73+
74+
<p>This attribute informs the system that you have tested against the target version and the
75+
system should not enable any compatibility behaviors to maintain your app's forward-compatibility
76+
with the target version. The application is still able to run on older versions (down to {@code
77+
minSdkVersion}).</p>
78+
79+
<p>As Android evolves with each new version, some behaviors and even appearances might change.
80+
However, if the API level of the platform is higher than the version declared by your app's {@code
81+
targetSdkVersion}, the system may enable compatibility behaviors to ensure that your app
82+
continues to work the way you expect. You can disable such compatibility
83+
behaviors by specifying {@code targetSdkVersion} to match the API
84+
level of the platform on which it's running. For example, setting this value to "11" or higher
85+
allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or
86+
higher and also disables <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
87+
compatibility mode</a> when running on larger screens (because support for API level 11 implicitly
88+
supports larger screens).</p>
89+
90+
<p>There are many compatibility behaviors that the system may enable based on the value you set
91+
for this attribute. Several of these behaviors are described by the corresponding platform versions
92+
in the {@link android.os.Build.VERSION_CODES} reference.</p>
93+
94+
<p>To maintain your application along with each Android release, you should increase
95+
the value of this attribute to match the latest API level, then thoroughly test your application on
96+
the corresponding platform version.</p>
8397

8498
<p>Introduced in: API Level 4</p>
8599
</dd>
@@ -89,25 +103,25 @@ href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>.</p>
89103
designed to run.
90104

91105
<p>In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this
92-
attribute when installing an application and when revalidating the application
106+
attribute when installing an application and when re-validating the application
93107
after a system update. In either case, if the application's
94-
<code>android:maxSdkVersion</code> attribute is lower than the API Level used by
108+
<code>maxSdkVersion</code> attribute is lower than the API Level used by
95109
the system itself, then the system will not allow the application to be
96-
installed. In the case of revalidation after system update, this effectively
110+
installed. In the case of re-validation after system update, this effectively
97111
removes your application from the device.
98112

99113
<p>To illustrate how this attribute can affect your application after system
100114
updates, consider the following example: </p>
101115

102-
<p>An application declaring <code>android:maxSdkVersion="5"</code> in its
116+
<p>An application declaring <code>maxSdkVersion="5"</code> in its
103117
manifest is published on Android Market. A user whose device is running Android
104118
1.6 (API Level 4) downloads and installs the app. After a few weeks, the user
105119
receives an over-the-air system update to Android 2.0 (API Level 5). After the
106120
update is installed, the system checks the application's
107-
<code>android:maxSdkVersion</code> and successfully revalidates it. The
121+
<code>maxSdkVersion</code> and successfully re-validates it. The
108122
application functions as normal. However, some time later, the device receives
109123
another system update, this time to Android 2.0.1 (API Level 6). After the
110-
update, the system can no longer revalidate the application because the system's
124+
update, the system can no longer re-validate the application because the system's
111125
own API Level (6) is now higher than the maximum supported by the application
112126
(5). The system prevents the application from being visible to the user, in
113127
effect removing it from the device.</p>
@@ -120,16 +134,16 @@ href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>.</p>
120134
provided it uses only standard APIs and follows development best practices.
121135
Second, note that in some cases, declaring the attribute can <strong>result in
122136
your application being removed from users' devices after a system
123-
update</strong> to a higher API Level. Most devices on which your appplication
137+
update</strong> to a higher API Level. Most devices on which your application
124138
is likely to be installed will receive periodic system updates over the air, so
125139
you should consider their effect on your application before setting this
126140
attribute.</p>
127141

128142
<p style="margin-bottom:1em;">Introduced in: API Level 4</p>
129143

130144
<div class="special">Future versions of Android (beyond Android 2.0.1) will no
131-
longer check or enforce the <code>android:maxSdkVersion</code> attribute during
132-
installation or revalidation. Android Market will continue to use the attribute
145+
longer check or enforce the <code>maxSdkVersion</code> attribute during
146+
installation or re-validation. Android Market will continue to use the attribute
133147
as a filter, however, when presenting users with applications available for
134148
download. </div>
135149
</dd>

0 commit comments

Comments
 (0)