├── settings.gradle
├── .gradle
└── 2.10
│ ├── taskArtifacts
│ ├── cache.properties
│ ├── fileHashes.bin
│ ├── fileSnapshots.bin
│ ├── taskArtifacts.bin
│ ├── outputFileStates.bin
│ └── cache.properties.lock
│ └── tasks
│ ├── _app_compileDebugJavaWithJavac
│ ├── localClassSetAnalysis
│ │ ├── localClassSetAnalysis.bin
│ │ └── localClassSetAnalysis.lock
│ └── localJarClasspathSnapshot
│ │ ├── localJarClasspathSnapshot.bin
│ │ └── localJarClasspathSnapshot.lock
│ └── _app_compileDebugAndroidTestJavaWithJavac
│ ├── localClassSetAnalysis
│ ├── localClassSetAnalysis.bin
│ └── localClassSetAnalysis.lock
│ └── localJarClasspathSnapshot
│ ├── localJarClasspathSnapshot.bin
│ └── localJarClasspathSnapshot.lock
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── app
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── activity_second.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── android
│ │ │ └── twoactivities
│ │ │ ├── SecondActivity.java
│ │ │ └── MainActivity.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── android
│ │ └── twoactivities
│ │ └── ActivityInputOutputTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── local.properties
├── gradle.properties
├── TwoActivities.iml
├── README.md
├── gradlew.bat
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':app'
2 |
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/cache.properties:
--------------------------------------------------------------------------------
1 | #Sun Nov 05 08:36:07 IST 2017
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/outputFileStates.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/taskArtifacts/outputFileStates.bin
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gradle/2.10/taskArtifacts/cache.properties.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/taskArtifacts/cache.properties.lock
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 11 11:01:21 PDT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
--------------------------------------------------------------------------------
/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/TwoActivitiesEspresso/master/.gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Sun Nov 05 08:32:48 IST 2017
11 | sdk.dir=/Users/lingaraj/Library/Android/sdk
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/llemay/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 | 16dp
17 | 16dp
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 | #3F51B5
17 | #303F9F
18 | #FF4081
19 |
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/TwoActivities.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.example.android.twoactivities"
9 | minSdkVersion 15
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | testCompile 'junit:junit:4.12'
26 | androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:24.1.0'
30 | androidTestCompile 'com.android.support:support-annotations:24.1.0'
31 | androidTestCompile 'com.android.support.test:runner:0.3'
32 | androidTestCompile 'com.android.support.test:rules:0.3'
33 | }
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | TwoActivities Sample App (Solution Code)
2 | ============
3 |
4 | The TwoActivities app contains two activities. It uses an explicit intent
5 | to launch one activity from another, and uses intent extras to pass data between them.
6 |
7 | Pre-requisites
8 | --------------
9 |
10 | For this app you should be familiar with:
11 | * Creating and running apps in Android Studio.
12 |
13 | Getting Started
14 | ---------------
15 |
16 | 1. Download and open the app in Android Studio.
17 |
18 | License
19 | -------
20 |
21 | Copyright 2016 Google, Inc.
22 |
23 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
24 | license agreements. See the NOTICE file distributed with this work for
25 | additional information regarding copyright ownership. The ASF licenses this
26 | file to you under the Apache License, Version 2.0 (the "License"); you may not
27 | use this file except in compliance with the License. You may obtain a copy of
28 | the License at
29 |
30 | http://www.apache.org/licenses/LICENSE-2.0
31 |
32 | Unless required by applicable law or agreed to in writing, software
33 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
34 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
35 | License for the specific language governing permissions and limitations under
36 | the License.
37 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 | Two Activities
17 |
18 |
19 | Second Activity
20 |
21 |
22 | Message Received
23 |
24 |
25 | Send
26 |
27 |
28 | Enter Your Message Here
29 |
30 |
31 | Reply
32 |
33 |
34 | Enter Your Reply Here
35 |
36 |
37 | Reply Received
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/android/twoactivities/ActivityInputOutputTest.java:
--------------------------------------------------------------------------------
1 | package com.example.android.twoactivities;
2 |
3 | import android.support.test.rule.ActivityTestRule;
4 | import android.support.test.runner.AndroidJUnit4;
5 |
6 | import org.junit.Rule;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static android.support.test.espresso.Espresso.onView;
11 | import static android.support.test.espresso.action.ViewActions.click;
12 | import static android.support.test.espresso.action.ViewActions.typeText;
13 | import static android.support.test.espresso.assertion.ViewAssertions.matches;
14 | import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
15 | import static android.support.test.espresso.matcher.ViewMatchers.withId;
16 | import static android.support.test.espresso.matcher.ViewMatchers.withText;
17 |
18 | /**
19 | * Created by lingaraj on 11/5/17.
20 | */
21 |
22 | @RunWith(AndroidJUnit4.class)
23 | public class ActivityInputOutputTest {
24 | @Rule
25 | public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class);
26 |
27 |
28 | //@Test
29 | public void activityLaunch(){
30 | onView(withId(R.id.button_main)).perform(click());
31 | onView(withId(R.id.text_header)).check(matches(isDisplayed()));
32 | onView(withId(R.id.button_second)).perform(click());
33 | onView(withId(R.id.text_header_reply)).check(matches(isDisplayed()));
34 |
35 | }
36 |
37 | @Test
38 | public void testEditTextInputOutput(){
39 | String text_one ="Hai man how are you";
40 | String text_reply = "Good, how is your life going bro";
41 | onView(withId(R.id.editText_main)).perform(typeText(text_one));
42 | onView(withId(R.id.button_main)).perform(click());
43 | onView(withId(R.id.text_message)).check(matches(withText(text_one)));
44 | onView(withId(R.id.editText_second)).perform(typeText(text_reply));
45 | onView(withId(R.id.button_second)).perform(click());
46 | onView(withId(R.id.text_message_reply)).check(matches(withText(text_reply)));
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
24 |
25 |
33 |
34 |
35 |
43 |
44 |
53 |
54 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
24 |
25 |
34 |
35 |
44 |
45 |
54 |
55 |
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/twoactivities/SecondActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Google Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example.android.twoactivities;
17 |
18 | import android.content.Intent;
19 | import android.support.v7.app.AppCompatActivity;
20 | import android.os.Bundle;
21 | import android.view.View;
22 | import android.widget.EditText;
23 | import android.widget.TextView;
24 |
25 | /**
26 | * SecondActivity defines the second activity in the app. It is launched from an intent
27 | * with a message, and sends an intent back with a second message.
28 | */
29 | public class SecondActivity extends AppCompatActivity {
30 | // Unique tag for the intent reply.
31 | public static final String EXTRA_REPLY =
32 | "com.example.android.twoactivities.extra.REPLY";
33 |
34 | // EditText for the reply.
35 | private EditText mReply;
36 |
37 | /**
38 | * Initializes the activity.
39 | *
40 | * @param savedInstanceState The current state data
41 | */
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_second);
46 |
47 | // Initialize view variables.
48 | mReply = (EditText) findViewById(R.id.editText_second);
49 |
50 | // Get the intent that launched this activity, and the message in
51 | // the intent extra.
52 | Intent intent = getIntent();
53 | String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
54 |
55 | // Put that message into the text_message TextView
56 | TextView textView = (TextView) findViewById(R.id.text_message);
57 | if (textView != null) {
58 | textView.setText(message);
59 | }
60 | }
61 |
62 | /**
63 | * Handle the onClick for the "Reply" button. Gets the message from the second EditText,
64 | * creates an intent, and returns that message back to the main activity.
65 | *
66 | * @param view The view (Button) that was clicked.
67 | */
68 | public void returnReply(View view) {
69 | // Get the reply message from the edit text.
70 | String reply = mReply.getText().toString();
71 |
72 | // Create a new intent for the reply, add the reply message to it as an extra,
73 | // set the intent result, and close the activity.
74 | Intent replyIntent = new Intent();
75 | replyIntent.putExtra(EXTRA_REPLY, reply);
76 | setResult(RESULT_OK, replyIntent);
77 | finish();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/twoactivities/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Google Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example.android.twoactivities;
17 |
18 | import android.content.Intent;
19 | import android.support.v7.app.AppCompatActivity;
20 | import android.os.Bundle;
21 | import android.util.Log;
22 | import android.view.View;
23 | import android.widget.EditText;
24 | import android.widget.TextView;
25 |
26 | /**
27 | * The TwoActivities app contains two activities and sends messages (intents) between them.
28 | */
29 | public class MainActivity extends AppCompatActivity {
30 | // Class name for Log tag
31 | private static final String LOG_TAG = MainActivity.class.getSimpleName();
32 | // Unique tag required for the intent extra
33 | public static final String EXTRA_MESSAGE = "com.example.android.twoactivities.extra.MESSAGE";
34 | // Unique tag for the intent reply
35 | public static final int TEXT_REQUEST = 1;
36 |
37 | // EditText view for the message
38 | private EditText mMessageEditText;
39 | // TextView for the reply header
40 | private TextView mReplyHeadTextView;
41 | // TextView for the reply body
42 | private TextView mReplyTextView;
43 |
44 | /**
45 | * Initializes the activity.
46 | *
47 | * @param savedInstanceState The current state data.
48 | */
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 | setContentView(R.layout.activity_main);
53 |
54 | // Initialize all the view variables.
55 | mMessageEditText = (EditText) findViewById(R.id.editText_main);
56 | mReplyHeadTextView = (TextView) findViewById(R.id.text_header_reply);
57 | mReplyTextView = (TextView) findViewById(R.id.text_message_reply);
58 | }
59 |
60 | /**
61 | * Handle the onClick for the "Send" button. Gets the value of the main EditText,
62 | * creates an intent, and launches the second activity with that intent.
63 | *
64 | * The return intent from the second activity is onActivityResult().
65 | * @param view The view (Button) that was clicked.
66 | */
67 | public void launchSecondActivity(View view) {
68 | Log.d(LOG_TAG, "Button clicked!");
69 |
70 | Intent intent = new Intent(this, SecondActivity.class);
71 | String message = mMessageEditText.getText().toString();
72 |
73 | intent.putExtra(EXTRA_MESSAGE, message);
74 | startActivityForResult(intent, TEXT_REQUEST);
75 | }
76 |
77 | /**
78 | * Handle the data in the return intent from SecondActivity.
79 | *
80 | * @param requestCode Code for the SecondActivity request.
81 | * @param resultCode Code that comes back from SecondActivity.
82 | * @param data Intent data sent back from SecondActivity.
83 | */
84 | @Override
85 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
86 | super.onActivityResult(requestCode, resultCode, data);
87 |
88 | // Test for the right intent reply
89 | if (requestCode == TEXT_REQUEST) {
90 | // Test to make sure the intent reply result was good.
91 | if (resultCode == RESULT_OK) {
92 | String reply = data.getStringExtra(SecondActivity.EXTRA_REPLY);
93 |
94 | // Make the reply head visible.
95 | mReplyHeadTextView.setVisibility(View.VISIBLE);
96 |
97 | // Set the reply and make it visible.
98 | mReplyTextView.setText(reply);
99 | mReplyTextView.setVisibility(View.VISIBLE);
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------