Permalink
Browse files

added ActivityResult project

  • Loading branch information...
1 parent 4b79702 commit 96715ac5088328a4c889bf1c180f91f93b3c960c @inazaruk committed Jul 5, 2011
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ActivityResult</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.inazaruk.activityresult"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="8" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".MainActivity"
+ 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=".ActivityA" android:label="A"/>
+ <activity android:name=".ActivityB" android:label="B"/>
+ <activity android:name=".ActivityC" android:label="C"/>
+
+ </application>
+</manifest>
@@ -0,0 +1,11 @@
+# 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 use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
@@ -0,0 +1,36 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Activity A"
+ />
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Start B"
+ android:onClick="onStartBClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="close"
+ android:onClick="onCloseClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="auto-close"
+ android:onClick="onAutoCloseClicked"/>
+
+
+</LinearLayout>
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Activity B"
+ />
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Start A"
+ android:onClick="onStartAClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Start C"
+ android:onClick="onStartCClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="close"
+ android:onClick="onCloseClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="auto-close"
+ android:onClick="onAutoCloseClicked"/>
+
+</LinearLayout>
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Activity C"
+ />
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="close"
+ android:onClick="onCloseClicked"/>
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="auto-close"
+ android:onClick="onAutoCloseClicked"/>
+
+</LinearLayout>
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, ActivityResultActivity!</string>
+ <string name="app_name">ActivityResult</string>
+</resources>
@@ -0,0 +1,25 @@
+package com.inazaruk.activityresult;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+public class ActivityA extends ActivityBase
+{
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.a);
+ }
+
+ public void onStartBClicked(View v)
+ {
+ startActivityForResult(new Intent(this, ActivityB.class),
+ ActivityHelper.AUTO_CLOSE_REQUEST_CODE);
+ }
+
+
+
+}
@@ -0,0 +1,27 @@
+package com.inazaruk.activityresult;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+public class ActivityB extends ActivityBase
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.b);
+ }
+
+ public void onStartAClicked(View v)
+ {
+ startActivityForResult(new Intent(this, ActivityA.class),
+ ActivityHelper.AUTO_CLOSE_REQUEST_CODE);
+ }
+
+ public void onStartCClicked(View v)
+ {
+ startActivityForResult(new Intent(this, ActivityC.class),
+ ActivityHelper.AUTO_CLOSE_REQUEST_CODE);
+ }
+}
@@ -0,0 +1,36 @@
+package com.inazaruk.activityresult;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Log;
+import android.view.View;
+
+public class ActivityBase extends Activity
+{
+ public void onCloseClicked(View v)
+ {
+ finish();
+ }
+
+ public void onAutoCloseClicked(View v)
+ {
+ setResult(ActivityHelper.AUTO_CLOSE_RESULT_CODE);
+ finish();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ if(requestCode == ActivityHelper.AUTO_CLOSE_REQUEST_CODE &&
+ requestCode == ActivityHelper.AUTO_CLOSE_RESULT_CODE)
+ {
+ Log.e(getClass().getSimpleName(), "onActivityResult - auto close, propagating");
+ setResult(ActivityHelper.AUTO_CLOSE_RESULT_CODE);
+ finish();
+ }
+ else
+ {
+ Log.e(getClass().getSimpleName(), "onActivityResult - no auto close");
+ }
+ }
+}
@@ -0,0 +1,13 @@
+package com.inazaruk.activityresult;
+
+import android.os.Bundle;
+
+public class ActivityC extends ActivityBase
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.c);
+ }
+}
@@ -0,0 +1,7 @@
+package com.inazaruk.activityresult;
+
+public class ActivityHelper
+{
+ public static final int AUTO_CLOSE_REQUEST_CODE = 1;
+ public static final int AUTO_CLOSE_RESULT_CODE = 1;
+}
@@ -0,0 +1,17 @@
+package com.inazaruk.activityresult;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class MainActivity extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ startActivity(new Intent(this, ActivityA.class));
+ }
+}

0 comments on commit 96715ac

Please sign in to comment.