summaryrefslogtreecommitdiffstats
path: root/Android/01-TheActivityClass
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-01-31 16:28:09 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:54 +0100
commite951bbe638b4af5330d68394a1a37e1b118bab28 (patch)
tree5268102bc54d3adc81ae112000c8b6b926f730f7 /Android/01-TheActivityClass
parent12a106bba4cf6ac9a8e9aa62c5f4fc4e6ba65b38 (diff)
downloadcoursera-e951bbe638b4af5330d68394a1a37e1b118bab28.zip
coursera-e951bbe638b4af5330d68394a1a37e1b118bab28.tar.gz
Android : 01-TheActivityClass: add
Diffstat (limited to 'Android/01-TheActivityClass')
-rw-r--r--Android/01-TheActivityClass/ActivityLab/AndroidManifest.xml31
-rw-r--r--Android/01-TheActivityClass/ActivityLab/build.xml92
-rw-r--r--Android/01-TheActivityClass/ActivityLab/ic_launcher-web.pngbin0 -> 55743 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/local.properties10
-rw-r--r--Android/01-TheActivityClass/ActivityLab/proguard-project.txt20
-rw-r--r--Android/01-TheActivityClass/ActivityLab/project.properties14
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/drawable-hdpi/ic_launcher.pngbin0 -> 8217 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/drawable-ldpi/ic_launcher.pngbin0 -> 2557 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/drawable-mdpi/ic_launcher.pngbin0 -> 4062 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/drawable-xhdpi/ic_launcher.pngbin0 -> 13563 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/layout/activity_one.xml32
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/layout/activity_two.xml33
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/values-v11/styles.xml11
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/values-v14/styles.xml12
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/values/strings.xml14
-rw-r--r--Android/01-TheActivityClass/ActivityLab/res/values/styles.xml20
-rw-r--r--Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityOne.java129
-rw-r--r--Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityTwo.java126
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/AndroidManifest.xml19
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/ant.properties18
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/build.xml92
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/libs/robotium-solo-5.0.1.jarbin0 -> 110489 bytes
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/local.properties10
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/proguard-project.txt20
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/project.properties14
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java52
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java62
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java64
-rw-r--r--Android/01-TheActivityClass/ActivityLifecycleWalkthrough.pdfbin0 -> 264437 bytes
-rw-r--r--Android/01-TheActivityClass/Lab-Activity.pdfbin0 -> 381454 bytes
-rw-r--r--Android/01-TheActivityClass/RobotiumTestCasesDecisionTree.pngbin0 -> 16860 bytes
31 files changed, 895 insertions, 0 deletions
diff --git a/Android/01-TheActivityClass/ActivityLab/AndroidManifest.xml b/Android/01-TheActivityClass/ActivityLab/AndroidManifest.xml
new file mode 100644
index 0000000..049a021
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="course.labs.activitylab"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="course.labs.activitylab.ActivityOne"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="course.labs.activitylab.ActivityTwo"
+ android:label="@string/title_activity_activity_two" >
+ </activity>
+ </application>
+
+</manifest> \ No newline at end of file
diff --git a/Android/01-TheActivityClass/ActivityLab/build.xml b/Android/01-TheActivityClass/ActivityLab/build.xml
new file mode 100644
index 0000000..914177e
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/build.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ActivityLab" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- if sdk.dir was not set from one of the property file, then
+ get it from the ANDROID_HOME env var.
+ This must be done before we load project.properties since
+ the proguard config can use sdk.dir -->
+ <property environment="env" />
+ <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+ <isset property="env.ANDROID_HOME" />
+ </condition>
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
diff --git a/Android/01-TheActivityClass/ActivityLab/ic_launcher-web.png b/Android/01-TheActivityClass/ActivityLab/ic_launcher-web.png
new file mode 100644
index 0000000..424f260
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/ic_launcher-web.png
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/local.properties b/Android/01-TheActivityClass/ActivityLab/local.properties
new file mode 100644
index 0000000..12a0114
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/local.properties
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/opt/android-sdk
diff --git a/Android/01-TheActivityClass/ActivityLab/proguard-project.txt b/Android/01-TheActivityClass/ActivityLab/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/Android/01-TheActivityClass/ActivityLab/project.properties b/Android/01-TheActivityClass/ActivityLab/project.properties
new file mode 100644
index 0000000..ce39f2d
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-18
diff --git a/Android/01-TheActivityClass/ActivityLab/res/drawable-hdpi/ic_launcher.png b/Android/01-TheActivityClass/ActivityLab/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..0e79b18
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/res/drawable-ldpi/ic_launcher.png b/Android/01-TheActivityClass/ActivityLab/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..ebfac7d
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/drawable-ldpi/ic_launcher.png
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/res/drawable-mdpi/ic_launcher.png b/Android/01-TheActivityClass/ActivityLab/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..1183441
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/res/drawable-xhdpi/ic_launcher.png b/Android/01-TheActivityClass/ActivityLab/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..c8ab2a1
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/res/layout/activity_one.xml b/Android/01-TheActivityClass/ActivityLab/res/layout/activity_one.xml
new file mode 100644
index 0000000..d281f0f
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/layout/activity_one.xml
@@ -0,0 +1,32 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <TextView android:id="@+id/create"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onCreate" />
+
+ <TextView android:id="@+id/start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onStart" />
+
+ <TextView android:id="@+id/resume"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onResume" />
+
+ <TextView android:id="@+id/restart"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onRestart" />
+
+ <Button android:id="@+id/bLaunchActivityTwo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/button" />
+
+</LinearLayout>
diff --git a/Android/01-TheActivityClass/ActivityLab/res/layout/activity_two.xml b/Android/01-TheActivityClass/ActivityLab/res/layout/activity_two.xml
new file mode 100644
index 0000000..5ccc915
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/layout/activity_two.xml
@@ -0,0 +1,33 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <TextView android:id="@+id/create"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onCreate" />
+
+ <TextView android:id="@+id/start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onStart" />
+
+ <TextView android:id="@+id/resume"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onResume" />
+
+ <TextView android:id="@+id/restart"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/onRestart" />
+
+ <Button android:id="@+id/bClose"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/close"
+ />
+
+</LinearLayout>
diff --git a/Android/01-TheActivityClass/ActivityLab/res/values-v11/styles.xml b/Android/01-TheActivityClass/ActivityLab/res/values-v11/styles.xml
new file mode 100644
index 0000000..541752f
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/Android/01-TheActivityClass/ActivityLab/res/values-v14/styles.xml b/Android/01-TheActivityClass/ActivityLab/res/values-v14/styles.xml
new file mode 100644
index 0000000..f20e015
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/Android/01-TheActivityClass/ActivityLab/res/values/strings.xml b/Android/01-TheActivityClass/ActivityLab/res/values/strings.xml
new file mode 100644
index 0000000..765f806
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/values/strings.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">ActivityLab</string>
+ <string name="menu_settings">Settings</string>
+ <string name="onCreate">onCreate() calls: 0</string>
+ <string name="onStart">onStart() calls: 0</string>
+ <string name="onResume">onResume() calls: 0</string>
+ <string name="onRestart">onRestart() calls: 0</string>
+ <string name="button">Start Activity Two</string>
+ <string name="title_activity_activity_two">Activity Two</string>
+ <string name="close">Close Activity</string>
+
+</resources>
diff --git a/Android/01-TheActivityClass/ActivityLab/res/values/styles.xml b/Android/01-TheActivityClass/ActivityLab/res/values/styles.xml
new file mode 100644
index 0000000..4a10ca4
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityOne.java b/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityOne.java
new file mode 100644
index 0000000..83e1df7
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityOne.java
@@ -0,0 +1,129 @@
+package course.labs.activitylab;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class ActivityOne extends Activity {
+
+ private static final String RESTART_KEY = "restart";
+ private static final String RESUME_KEY = "resume";
+ private static final String START_KEY = "start";
+ private static final String CREATE_KEY = "create";
+
+ // String for LogCat documentation
+ private final static String TAG = "Lab-ActivityOne";
+
+ // Lifecycle counters
+
+ // TODO:
+ // Create counter variables for onCreate(), onRestart(), onStart() and
+ // onResume(), called mCreate, etc.
+ // You will need to increment these variables' values when their
+ // corresponding lifecycle methods get called
+
+ // TODO: Create variables for each of the TextViews, called
+ // mTvCreate, etc.
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_one);
+
+ // TODO: Assign the appropriate TextViews to the TextView variables
+ // Hint: Access the TextView by calling Activity's findViewById()
+ // textView1 = (TextView) findViewById(R.id.textView1);
+
+ Button launchActivityTwoButton = (Button) findViewById(R.id.bLaunchActivityTwo);
+ launchActivityTwoButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO:
+ // Launch Activity Two
+ // Hint: use Context's startActivity() method
+ // Create an intent stating which Activity you would like to start
+ // Launch the Activity using the intent
+ }
+ });
+
+ // Check for previously saved state
+ if (savedInstanceState != null) {
+ // TODO:
+ // Restore value of counters from saved state
+ // Only need 4 lines of code, one for every count variable
+ }
+
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface via the displayCounts() method
+ }
+
+ // Lifecycle callback overrides
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onRestart() {
+ super.onRestart();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ // TODO:
+ // Save state information with a collection of key-value pairs
+ // 4 lines of code, one for every count variable
+ }
+
+ // Updates the displayed counters
+ public void displayCounts() {
+ mTvCreate.setText("onCreate() calls: " + mCreate);
+ mTvStart.setText("onStart() calls: " + mStart);
+ mTvResume.setText("onResume() calls: " + mResume);
+ mTvRestart.setText("onRestart() calls: " + mRestart);
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityTwo.java b/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityTwo.java
new file mode 100644
index 0000000..edd3951
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/src/course/labs/activitylab/ActivityTwo.java
@@ -0,0 +1,126 @@
+package course.labs.activitylab;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class ActivityTwo extends Activity {
+
+ private static final String RESTART_KEY = "restart";
+ private static final String RESUME_KEY = "resume";
+ private static final String START_KEY = "start";
+ private static final String CREATE_KEY = "create";
+
+ // String for LogCat documentation
+ private final static String TAG = "Lab-ActivityTwo";
+
+ // Lifecycle counters
+
+ // TODO:
+ // Create counter variables for onCreate(), onRestart(), onStart() and
+ // onResume(), called mCreate, etc.
+ // You will need to increment these variables' values when their
+ // corresponding lifecycle methods get called
+
+ // TODO: Create variables for each of the TextViews, called
+ // mTvCreate, etc.
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_two);
+
+ // TODO: Assign the appropriate TextViews to the TextView variables
+ // Hint: Access the TextView by calling Activity's findViewById()
+ // textView1 = (TextView) findViewById(R.id.textView1);
+
+ Button closeButton = (Button) findViewById(R.id.bClose);
+ closeButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO:
+ // This function closes Activity Two
+ // Hint: use Context's finish() method
+ }
+ });
+
+ // Check for previously saved state
+ if (savedInstanceState != null) {
+ // TODO:
+ // Restore value of counters from saved state
+ // Only need 4 lines of code, one for every count variable
+ }
+
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface via the displayCounts() method
+ }
+
+ // Lifecycle callback methods overrides
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onRestart() {
+ super.onRestart();
+ // TODO: Emit LogCat message
+ // TODO:
+ // Update the appropriate count variable
+ // Update the user interface
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ // TODO: Emit LogCat message
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ // TODO:
+ // Save counter state information with a collection of key-value pairs
+ // 4 lines of code, one for every count variable
+ }
+
+ // Updates the displayed counters
+ public void displayCounts() {
+ mTvCreate.setText("onCreate() calls: " + mCreate);
+ mTvStart.setText("onStart() calls: " + mStart);
+ mTvResume.setText("onResume() calls: " + mResume);
+ mTvRestart.setText("onRestart() calls: " + mRestart);
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/AndroidManifest.xml b/Android/01-TheActivityClass/ActivityLab/tests/AndroidManifest.xml
new file mode 100644
index 0000000..ddeb1ed
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="course.labs.activitylab.test"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <uses-sdk android:minSdkVersion="16" />
+
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="course.labs.activitylab" />
+
+ <application android:label="course.labs.activitylab.test" >
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+</manifest>
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/ant.properties b/Android/01-TheActivityClass/ActivityLab/tests/ant.properties
new file mode 100644
index 0000000..836edf0
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/ant.properties
@@ -0,0 +1,18 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked into Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
+tested.project.dir=../
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/build.xml b/Android/01-TheActivityClass/ActivityLab/tests/build.xml
new file mode 100644
index 0000000..0e19468
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/build.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ActivityLabTest" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- if sdk.dir was not set from one of the property file, then
+ get it from the ANDROID_HOME env var.
+ This must be done before we load project.properties since
+ the proguard config can use sdk.dir -->
+ <property environment="env" />
+ <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+ <isset property="env.ANDROID_HOME" />
+ </condition>
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/libs/robotium-solo-5.0.1.jar b/Android/01-TheActivityClass/ActivityLab/tests/libs/robotium-solo-5.0.1.jar
new file mode 100644
index 0000000..fb61e41
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/libs/robotium-solo-5.0.1.jar
Binary files differ
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/local.properties b/Android/01-TheActivityClass/ActivityLab/tests/local.properties
new file mode 100644
index 0000000..12a0114
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/local.properties
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/opt/android-sdk
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/proguard-project.txt b/Android/01-TheActivityClass/ActivityLab/tests/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/project.properties b/Android/01-TheActivityClass/ActivityLab/tests/project.properties
new file mode 100644
index 0000000..ce39f2d
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-18
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java
new file mode 100644
index 0000000..6f85ad3
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java
@@ -0,0 +1,52 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test1 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test1() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.LANDSCAPE);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 2"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.PORTRAIT);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 3"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 3"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 3"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java
new file mode 100644
index 0000000..89fd34e
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java
@@ -0,0 +1,62 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test2 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test2() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.LANDSCAPE);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 2"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.PORTRAIT);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 3"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 3"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 3"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java
new file mode 100644
index 0000000..5582c13
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java
@@ -0,0 +1,64 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test3 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test3() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Close Activity
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bClose));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 1"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLifecycleWalkthrough.pdf b/Android/01-TheActivityClass/ActivityLifecycleWalkthrough.pdf
new file mode 100644
index 0000000..caf0681
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLifecycleWalkthrough.pdf
Binary files differ
diff --git a/Android/01-TheActivityClass/Lab-Activity.pdf b/Android/01-TheActivityClass/Lab-Activity.pdf
new file mode 100644
index 0000000..eee5512
--- /dev/null
+++ b/Android/01-TheActivityClass/Lab-Activity.pdf
Binary files differ
diff --git a/Android/01-TheActivityClass/RobotiumTestCasesDecisionTree.png b/Android/01-TheActivityClass/RobotiumTestCasesDecisionTree.png
new file mode 100644
index 0000000..ef255ee
--- /dev/null
+++ b/Android/01-TheActivityClass/RobotiumTestCasesDecisionTree.png
Binary files differ