diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index e28a09691..5eb8ccb22 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -108,6 +108,13 @@
+
+
+
+
+
+
+
diff --git a/samples/ApiDemos/res/anim/fade.xml b/samples/ApiDemos/res/anim/fade.xml
index 78b193d53..617c5f253 100644
--- a/samples/ApiDemos/res/anim/fade.xml
+++ b/samples/ApiDemos/res/anim/fade.xml
@@ -16,4 +16,5 @@
+ android:fromAlpha="0.0" android:toAlpha="1.0"
+ android:duration="@android:integer/config_longAnimTime" />
diff --git a/samples/ApiDemos/res/anim/hold.xml b/samples/ApiDemos/res/anim/hold.xml
new file mode 100644
index 000000000..65fbacfc6
--- /dev/null
+++ b/samples/ApiDemos/res/anim/hold.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/samples/ApiDemos/res/anim/slide_left.xml b/samples/ApiDemos/res/anim/slide_left.xml
index 87604919f..0a591b05a 100644
--- a/samples/ApiDemos/res/anim/slide_left.xml
+++ b/samples/ApiDemos/res/anim/slide_left.xml
@@ -15,5 +15,6 @@
-->
-
+
diff --git a/samples/ApiDemos/res/anim/slide_right.xml b/samples/ApiDemos/res/anim/slide_right.xml
index 7aaacdb0a..edeed2472 100644
--- a/samples/ApiDemos/res/anim/slide_right.xml
+++ b/samples/ApiDemos/res/anim/slide_right.xml
@@ -15,5 +15,6 @@
-->
-
+
diff --git a/samples/ApiDemos/res/anim/zoom_enter.xml b/samples/ApiDemos/res/anim/zoom_enter.xml
new file mode 100644
index 000000000..7c29852a8
--- /dev/null
+++ b/samples/ApiDemos/res/anim/zoom_enter.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
diff --git a/samples/ApiDemos/res/anim/zoom_exit.xml b/samples/ApiDemos/res/anim/zoom_exit.xml
new file mode 100644
index 000000000..29dfe99a6
--- /dev/null
+++ b/samples/ApiDemos/res/anim/zoom_exit.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
diff --git a/samples/ApiDemos/res/layout/activity_animation.xml b/samples/ApiDemos/res/layout/activity_animation.xml
new file mode 100644
index 000000000..446f73585
--- /dev/null
+++ b/samples/ApiDemos/res/layout/activity_animation.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 122483e62..2800bff53 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -47,6 +47,11 @@
App/Activity/Translucent Blur
+ App/Activity/Animation
+ Press a button to launch an activity with a custom animation.
+ Fade in
+ Zoom in
+
App/Activity/Save & Restore StateDemonstration of saving and restoring activity state in onSaveInstanceState() and onCreate().This text field saves its state:
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
new file mode 100644
index 000000000..90831f5d5
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.app;
+
+// Need the following import to get access to the app resources, since this
+// class is in a sub-package.
+import com.example.android.apis.R;
+import com.example.android.apis.view.Controls1;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+
+/**
+ *
Example of explicitly starting and stopping the {@link LocalService}.
+ * This demonstrates the implementation of a service that runs in the same
+ * process as the rest of the application, which is explicitly started and stopped
+ * as desired.
+ */
+public class Animation extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_animation);
+
+ // Watch for button clicks.
+ Button button = (Button)findViewById(R.id.fade_animation);
+ button.setOnClickListener(mFadeListener);
+ button = (Button)findViewById(R.id.zoom_animation);
+ button.setOnClickListener(mZoomListener);
+ }
+
+ private OnClickListener mFadeListener = new OnClickListener() {
+ public void onClick(View v) {
+ // Request the next activity transition (here starting a new one).
+ startActivity(new Intent(Animation.this, Controls1.class));
+ // Supply a custom animation. This one will just fade the new
+ // activity on top. Note that we need to also supply an animation
+ // (here just doing nothing for the same amount of time) for the
+ // old activity to prevent it from going away too soon.
+ overridePendingTransition(R.anim.fade, R.anim.hold);
+ }
+ };
+
+ private OnClickListener mZoomListener = new OnClickListener() {
+ public void onClick(View v) {
+ // Request the next activity transition (here starting a new one).
+ startActivity(new Intent(Animation.this, Controls1.class));
+ // This is a more complicated animation, involving transformations
+ // on both this (exit) and the new (enter) activity. Note how for
+ // the duration of the animation we force the exiting activity
+ // to be Z-ordered on top (even though it really isn't) to achieve
+ // the effect we want.
+ overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
+ }
+ };
+}
+
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java b/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
index 87915784b..79324a43c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
+import android.util.Log;
import android.widget.Toast;
// Need the following import to get access to the app resources, since this
@@ -63,6 +64,14 @@ public class LocalService extends Service {
showNotification();
}
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Log.i("LocalService", "Received start id " + startId + ": " + intent);
+ // We want this service to continue running until it is explicitly
+ // stopped, so return sticky.
+ return START_STICKY;
+ }
+
@Override
public void onDestroy() {
// Cancel the persistent notification.