Add API demo of a heavy-weight application.
Change-Id: I15e2d1c766af8aa7a62beed3069b8d128338ca11
This commit is contained in:
@@ -91,6 +91,7 @@ development/samples/LunarLander samples/${PLATFORM_NAME}/LunarLande
|
||||
development/samples/NotePad samples/${PLATFORM_NAME}/NotePad
|
||||
development/samples/ApiDemos samples/${PLATFORM_NAME}/ApiDemos
|
||||
development/samples/BackupRestore samples/${PLATFORM_NAME}/BackupRestore
|
||||
development/samples/NotePad samples/${PLATFORM_NAME}/HeavyWeight
|
||||
development/samples/SampleSyncAdapter samples/${PLATFORM_NAME}/SampleSyncAdapter
|
||||
development/samples/SkeletonApp samples/${PLATFORM_NAME}/SkeletonApp
|
||||
development/samples/Snake samples/${PLATFORM_NAME}/Snake
|
||||
|
||||
16
samples/HeavyWeight/Android.mk
Normal file
16
samples/HeavyWeight/Android.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := samples
|
||||
|
||||
# Only compile source java files in this apk.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := HeavyWeight
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
32
samples/HeavyWeight/AndroidManifest.xml
Normal file
32
samples/HeavyWeight/AndroidManifest.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<!-- Declare the contents of this Android application. The namespace
|
||||
attribute brings in the Android platform namespace, and the package
|
||||
supplies a unique name for the application. When writing your
|
||||
own application, the package name must be changed from "com.example.*"
|
||||
to come from a domain that you own or have control over. -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.android.heavyweight">
|
||||
<application android:label="Heavy Weight" android:heavyWeight="true">
|
||||
<activity android:name="HeavyWeight">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
34
samples/HeavyWeight/res/layout/heavy_weight.xml
Normal file
34
samples/HeavyWeight/res/layout/heavy_weight.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:padding="4dip"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:paddingBottom="4dp"
|
||||
android:text="@string/content_text"/>
|
||||
|
||||
<Button android:id="@+id/stop"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:text="@string/stop">
|
||||
<requestFocus />
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
22
samples/HeavyWeight/res/values/strings.xml
Normal file
22
samples/HeavyWeight/res/values/strings.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="content_text">A heavy-weight application will not be killed until explicitly stopped.</string>
|
||||
<string name="stop">Stop</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.heavyweight;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
/**
|
||||
* Basic "heavy-weight" application, which will not be killed by Android
|
||||
* while it is in the background.
|
||||
*/
|
||||
public class HeavyWeight extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.heavy_weight);
|
||||
|
||||
Button button = (Button)findViewById(R.id.stop);
|
||||
button.setOnClickListener(mStopListener);
|
||||
}
|
||||
|
||||
private OnClickListener mStopListener = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@ import android.os.Bundle;
|
||||
* A minimal "Hello, World!" application.
|
||||
*/
|
||||
public class HelloActivity extends Activity {
|
||||
public HelloActivity() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called with the activity is first created.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user