├── .gitignore ├── Alice ├── .gitignore ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── co │ │ └── infinum │ │ └── sharedprocess │ │ └── alice │ │ └── MainActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── menu │ └── main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── Bob ├── .gitignore ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── co │ │ └── infinum │ │ └── sharedprocess │ │ └── bob │ │ └── MainActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main2.xml │ ├── menu │ └── main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── README.md ├── build.gradle ├── common.keystore ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Intellij project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | 31 | #Gradle 32 | .gradle 33 | 34 | 35 | /local.properties 36 | 37 | .DS_Store 38 | -------------------------------------------------------------------------------- /Alice/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Alice/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion "19.0.1" 6 | 7 | signingConfigs { 8 | release { 9 | keyAlias 'android' 10 | storeFile file('../common.keystore') 11 | keyPassword 'karlovac' 12 | storePassword 'karlovac' 13 | } 14 | } 15 | 16 | defaultConfig { 17 | minSdkVersion 7 18 | targetSdkVersion 19 19 | versionCode 1 20 | versionName "1.0" 21 | } 22 | buildTypes { 23 | release { 24 | runProguard false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 26 | signingConfig signingConfigs.release 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | compile 'com.android.support:appcompat-v7:+' 33 | } 34 | -------------------------------------------------------------------------------- /Alice/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 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 | #} -------------------------------------------------------------------------------- /Alice/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Alice/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikust/hello-sharedprocess/97e94dcfdc8ba06634a8f5f88cbfbe3e2ffac381/Alice/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /Alice/src/main/java/co/infinum/sharedprocess/alice/MainActivity.java: -------------------------------------------------------------------------------- 1 | package co.infinum.sharedprocess.alice; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.content.res.Resources; 7 | import android.os.Bundle; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.view.View; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | 13 | /** 14 | * An Activity that demonstrates starting Activity from another application sharing the same 15 | * sharedUserId and passing data to it. 16 | *

17 | * A prerequisite for this is that sharedUserId must be set in AndroidManifests of both applications 18 | * to the same value, and both applications must be signed with the same keystore. 19 | */ 20 | public class MainActivity extends ActionBarActivity { 21 | 22 | /** 23 | * Fully qualified name of Bob's activity that will be started. 24 | */ 25 | private static final String BOBS_MAIN_ACTIIVTY = "co.infinum.sharedprocess.bob.MainActivity"; 26 | 27 | /** 28 | * Package identifier of Bob's application. 29 | */ 30 | private static final String BOBS_PACKAGE = "co.infinum.sharedprocess.bob"; 31 | 32 | /** 33 | * Key of the extra that will be passed to Bob's activity. 34 | */ 35 | private static final String EXTRA_SECRET_MESSAGE = "message"; 36 | 37 | /** 38 | * Edit text for entering message to send. 39 | */ 40 | private EditText messageEditText; 41 | 42 | /** 43 | * Send button. 44 | */ 45 | private Button sendButton; 46 | 47 | @Override 48 | protected void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | setContentView(R.layout.activity_main); 51 | 52 | final EditText messageEditText = (EditText) findViewById(R.id.editTextMessage); 53 | Button sendButton = (Button) findViewById(R.id.buttonSend); 54 | 55 | sendButton.setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View view) { 58 | tellSecretToBob(messageEditText.getText().toString()); 59 | } 60 | }); 61 | } 62 | 63 | /** 64 | * Returns a resource identifier for a given resource name and type. 65 | * 66 | * @param resourceName name of the resource 67 | * @param resourceType type of the resource (e.g. drawable, string, layout...) 68 | * @return resource identifier or 0 if there is no such resource 69 | */ 70 | public int getBobsResource(String resourceName, String resourceType) { 71 | PackageManager pm = getPackageManager(); 72 | 73 | Resources resources = null; 74 | if (pm != null) { 75 | try { 76 | resources = pm.getResourcesForApplication(BOBS_PACKAGE); 77 | 78 | int res = resources.getIdentifier(resourceName, resourceType, BOBS_PACKAGE); 79 | } catch (PackageManager.NameNotFoundException e) { 80 | e.printStackTrace(); 81 | } 82 | } 83 | 84 | return 0; 85 | } 86 | 87 | /** 88 | * Starts Bob's activity defined with fully qualified class name in BOBS_MAIN_ACTIVITY constant. 89 | * Bob's application package name is defined in BOBS_PACKAGE. A String extra with the key 90 | * EXTRA_SECRET_MESSAGE is passed, containing the message given in argument. 91 | * 92 | * @param message message to pass to Bob's activity 93 | */ 94 | public void tellSecretToBob(String message) { 95 | Intent intent = new Intent(); 96 | 97 | intent.setComponent(new ComponentName(BOBS_PACKAGE, BOBS_MAIN_ACTIIVTY)); 98 | intent.putExtra(EXTRA_SECRET_MESSAGE, message); 99 | startActivity(intent); 100 | } 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /Alice/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikust/hello-sharedprocess/97e94dcfdc8ba06634a8f5f88cbfbe3e2ffac381/Alice/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Alice/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikust/hello-sharedprocess/97e94dcfdc8ba06634a8f5f88cbfbe3e2ffac381/Alice/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Alice/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikust/hello-sharedprocess/97e94dcfdc8ba06634a8f5f88cbfbe3e2ffac381/Alice/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Alice/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikust/hello-sharedprocess/97e94dcfdc8ba06634a8f5f88cbfbe3e2ffac381/Alice/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Alice/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | 14 | 18 | 19 |