summaryrefslogtreecommitdiffstats
path: root/docs/html/training/basics/firstapp
diff options
context:
space:
mode:
authorScott Main <smain@google.com>2013-01-04 17:41:54 -0800
committerScott Main <smain@google.com>2013-01-04 18:09:29 -0800
commitf8daf19971606a9fa27339747318ac061321bcb1 (patch)
treeac0c7276d11600457e0b532fdcc0b597ff66c5f0 /docs/html/training/basics/firstapp
parent197d0a6688ccf72632b461987671f1f2802935b7 (diff)
downloadframeworks_base-f8daf19971606a9fa27339747318ac061321bcb1.zip
frameworks_base-f8daf19971606a9fa27339747318ac061321bcb1.tar.gz
frameworks_base-f8daf19971606a9fa27339747318ac061321bcb1.tar.bz2
docs: misc bug fixes. including important versioning fixes for first app class
Change-Id: Ifda2509fc90dd795bfd6c5e9b3d7eebcbd77892a
Diffstat (limited to 'docs/html/training/basics/firstapp')
-rw-r--r--docs/html/training/basics/firstapp/running-app.jd22
-rw-r--r--docs/html/training/basics/firstapp/starting-activity.jd19
2 files changed, 37 insertions, 4 deletions
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 7866083..999d399 100644
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -52,7 +52,27 @@ project:</p>
<dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes
the fundamental characteristics of the app and defines each of
its components. You'll learn about various declarations in this file as you read more training
-classes.</dd>
+classes.
+ <p>One of the most important elements your manifest should include is the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk>}</a>
+element. This declares your app's compatibility with different Android versions using the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
+and <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code android:targetSdkVersion}</a>
+attributes. For your first app, it should look like this:</p>
+<pre>
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
+ &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
+ ...
+&lt;/manifest>
+</pre>
+<p>You should always set the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code android:targetSdkVersion}</a>
+as high as possible and test your app on the corresponding platform version. For more information,
+read <a href="{@docRoot}training/basics/supporting-devices/platforms.html">Supporting Different
+Platform Versions</a>.</p>
+
+ </dd>
<dt><code>src/</code></dt>
<dd>Directory for your app's main source files. By default, it includes an {@link
android.app.Activity} class that runs when your app is launched using the app icon.</dd>
diff --git a/docs/html/training/basics/firstapp/starting-activity.jd b/docs/html/training/basics/firstapp/starting-activity.jd
index 8943c9d..65f22901 100644
--- a/docs/html/training/basics/firstapp/starting-activity.jd
+++ b/docs/html/training/basics/firstapp/starting-activity.jd
@@ -249,16 +249,29 @@ you won't need it for this app so you can remove it.</li>
Keep this one the way it is.</li>
</ul>
-<p>The class should look like this:</p>
+<p>Because the {@link android.app.ActionBar} APIs are available only on {@link
+android.os.Build.VERSION_CODES#HONEYCOMB} (API level 11) and higher, you must add a condition
+around the {@link android.app.Activity#getActionBar()} method to check the current platform version.
+Additionally, you must add the {@code &#64;SuppressLint("NewApi")} tag to the
+{@link android.app.Activity#onCreate onCreate()} method to avoid <a
+href="{@docRoot}tools/help/lint.html">lint</a> errors.</p>
+
+<p>The {@code DisplayMessageActivity} class should now look like this:</p>
<pre>
public class DisplayMessageActivity extends Activity {
+
+ &#64;SuppressLint("NewApi")
&#64;Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
- // Show the Up button in the action bar.
- getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ // Make sure we're running on Honeycomb or higher to use ActionBar APIs
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ // Show the Up button in the action bar.
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
}
&#64;Override