├── .gitignore ├── Diagram.png ├── README.md ├── SmConsumer ├── .gitignore ├── .idea │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── runConfigurations.xml ├── app │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── newtronlabs │ │ │ └── smconsumerdemo │ │ │ ├── MainActivity.java │ │ │ └── RemoteBitmapTask.java │ │ └── res │ │ ├── drawable │ │ └── image_holder_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── 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-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle └── SmProducer ├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── newtronlabs │ │ └── smproducerdemo │ │ ├── MainActivity.java │ │ └── ShareBitmapTask.java │ └── res │ ├── drawable │ ├── image_holder_background.xml │ └── newtron.png │ ├── layout │ └── activity_main.xml │ ├── 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-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── 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 ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | SmProducer/app/proguard-rules.pro 43 | 44 | SmConsumer/app/proguard-rules.pro 45 | -------------------------------------------------------------------------------- /Diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/Diagram.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shared Memory 2 | 3 | The Shared Memory library allows for the creation of memory regions that may be simultaneously accessed by multiple Android processes or applications. Developed to overcome the Android 1MB IPC limitation, this Shared Memory library allows you to exchange larger amounts of data between your Android applications. 4 | 5 |

6 | 7 |

8 | 9 | ---- 10 | 11 | ## How to Use 12 | 13 | ### Setup 14 | 15 | Include the below dependencies in your `build.gradle` project. 16 | 17 | ```gradle 18 | buildscript { 19 | repositories { 20 | google() 21 | maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" } 22 | } 23 | dependencies { 24 | classpath 'com.android.tools.build:gradle:7.0.4' 25 | classpath 'com.newtronlabs.android:plugin:5.0.2' 26 | } 27 | } 28 | 29 | allprojects { 30 | repositories { 31 | google() 32 | maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" } 33 | } 34 | } 35 | 36 | subprojects { 37 | apply plugin: 'com.newtronlabs.android' 38 | } 39 | ``` 40 | 41 | In the `build.gradle` for your app. 42 | 43 | ```gradle 44 | dependencies { 45 | compileOnly 'com.newtronlabs.sharedmemory:sharedmemory:5.0.0-alpha01' 46 | } 47 | ``` 48 | 49 | ### Sharing Memory - Producer 50 | From the application that wishes to shared its memory, allocate a shated memory region with a given name. 51 | 52 | ```java 53 | // Allocate 2MB 54 | int sizeInBytes = 2*(1024*1024); 55 | String regionName = "Test-Region"; 56 | ISharedMemory sharedMemory = SharedMemoryProducer.getInstance().allocate(regionName, sizeInBytes); 57 | ``` 58 | 59 | Write data to memory: 60 | ```java 61 | byte[] strBytes = "Hello World!".getBytes(); 62 | sharedMemory.writeBytes(strBytes, 0, 0, strBytes.length); 63 | ``` 64 | 65 | Once an application has shared a memory region it can be accessed by other processes or application which are aware of it. 66 | 67 | ### Accessing Shared Memory - Consumer 68 | In order for an application to access a region of memory shaered by an external application perform the following: 69 | 70 | ```java 71 | // This is the application id of the application or process which shared the region. 72 | String producerAppId = "com.newtronlabs.smproducerdemo"; 73 | 74 | // Name under wich the remote region was created. 75 | String regionName = "Test-Region" 76 | 77 | // Note: The remote application must have allocated a memory region with the same 78 | // name or this call will fail and return null. 79 | IRemoteSharedMemory remoteMemory 80 | = RemoteMemoryAdapter.getDefaultAdapter().getSharedMemory(context, producerAppId, regionName); 81 | 82 | // Allocate memory to read shared content. 83 | byte[] dataBytes = new byte[remoteMemory.getSize()]; 84 | String dataStr = new String(dataBytes); 85 | Log.d("Newtron", "Memory Read:"+dataStr); 86 | ``` 87 | 88 | ### Additional Samples 89 | A set of more complex exmaples can be found in this repo's samples folders: **SmProducer** and **SmConsumer**. 90 | 91 | --- 92 | 93 | ## Support Us 94 | Please support the continued development of these libraries. We host and develop these libraries for free. Any support is deeply appriciated. Thank you! 95 | 96 |

97 | Support us 98 |

99 | 100 |

101 | BTC Address: 39JmAfnNhaEPKz5wjQjQQj4jcv9BM11NQb 102 |

103 | 104 | 105 | --- 106 | ## License 107 | 108 | https://gist.github.com/NewtronLabs/216f45db2339e0bc638e7c14a6af9cc8 109 | 110 | ## Contact 111 | 112 | solutions@newtronlabs.com 113 | -------------------------------------------------------------------------------- /SmConsumer/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | 11 | # Built application files 12 | *.apk 13 | *.ap_ 14 | 15 | # Files for the ART/Dalvik VM 16 | *.dex 17 | 18 | # Java class files 19 | *.class 20 | 21 | # Generated files 22 | bin/ 23 | gen/ 24 | out/ 25 | 26 | # Gradle files 27 | .gradle/ 28 | build/ 29 | 30 | # Local configuration file (sdk path, etc) 31 | local.properties 32 | 33 | # Proguard folder generated by Eclipse 34 | proguard/ 35 | 36 | # Log Files 37 | *.log 38 | 39 | # Android Studio Navigation editor temp files 40 | .navigation/ 41 | 42 | # Android Studio captures folder 43 | captures/ 44 | 45 | # Intellij 46 | *.iml 47 | .idea/workspace.xml 48 | .idea/tasks.xml 49 | .idea/gradle.xml 50 | .idea/dictionaries 51 | .idea/libraries 52 | 53 | # Keystore files 54 | # Uncomment the following line if you do not want to check your keystore files in. 55 | #*.jks 56 | 57 | # External native build folder generated in Android Studio 2.2 and later 58 | .externalNativeBuild 59 | 60 | # Google Services (e.g. APIs or Firebase) 61 | google-services.json 62 | 63 | # Freeline 64 | freeline.py 65 | freeline/ 66 | freeline_project_description.json 67 | -------------------------------------------------------------------------------- /SmConsumer/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SmConsumer/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /SmConsumer/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | -------------------------------------------------------------------------------- /SmConsumer/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SmConsumer/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /SmConsumer/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /SmConsumer/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.newtronlabs.smconsumerdemo" 8 | minSdkVersion 13 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:25.2.0' 24 | 25 | // Shared Memory Library 26 | provided 'com.newtronlabs.sharedmemory:sharedmemory:3.0.0' 27 | } 28 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/java/com/newtronlabs/smconsumerdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.smconsumerdemo; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.newtronlabs.sharedmemory.IRemoteSharedMemory; 11 | 12 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, RemoteBitmapTask.OnRemoteBitmapListener 13 | { 14 | 15 | /** 16 | * Sample: Name of the Shared Memory region allocated by the producer application. 17 | */ 18 | private static final String mRemoteRegionName = "Test-Region"; 19 | 20 | /** 21 | * Sample: Application id of the producer application. 22 | */ 23 | private static final String mRemoteAppId = "com.newtronlabs.smproducerdemo"; 24 | 25 | /** 26 | * Shared Memory object to interact with the remote memory allocated 27 | * by the producer application. 28 | */ 29 | private IRemoteSharedMemory mSharedMemory; 30 | 31 | private ImageView mRemoteImageView; 32 | private TextView mMessageView; 33 | private Bitmap mLastBitmap; 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) 36 | { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_main); 39 | 40 | Object savedState = getLastCustomNonConfigurationInstance(); 41 | if(savedState instanceof IRemoteSharedMemory) 42 | { 43 | // Reuse the shared memory reference. 44 | mSharedMemory = (IRemoteSharedMemory)savedState; 45 | } 46 | 47 | mRemoteImageView = (ImageView)findViewById(R.id.img_remote); 48 | mMessageView = (TextView)findViewById(R.id.tv_message); 49 | 50 | View content = findViewById(R.id.content_holder); 51 | content.setOnClickListener(this); 52 | } 53 | 54 | @Override 55 | public Object onRetainCustomNonConfigurationInstance() 56 | { 57 | // Preserve the shared memory reference across the activity config change. 58 | return mSharedMemory; 59 | } 60 | 61 | @Override 62 | public void onClick(View view) 63 | { 64 | if(view.getId() == R.id.content_holder) 65 | { 66 | /** 67 | * Try to access the remote shared memory. 68 | * This will fail if: 69 | * - The remote application is not installed. 70 | * - The remote application has not shared a region with the specified name. 71 | */ 72 | RemoteBitmapTask task = new RemoteBitmapTask(this, mRemoteAppId, mRemoteRegionName, this); 73 | task.execute(); 74 | } 75 | } 76 | 77 | @Override 78 | public void onBitmapRetrieved(Bitmap remoteBitmap, String producerAppId, String regionName) 79 | { 80 | if(remoteBitmap == null) 81 | { 82 | mRemoteImageView.setVisibility(View.GONE); 83 | mMessageView.setVisibility(View.VISIBLE); 84 | mMessageView.setText(R.string.usage_message_failed); 85 | } 86 | else 87 | { 88 | mMessageView.setVisibility(View.GONE); 89 | mRemoteImageView.setVisibility(View.VISIBLE); 90 | mRemoteImageView.setImageBitmap(remoteBitmap); 91 | 92 | if(mLastBitmap != null && !mLastBitmap.isRecycled()) 93 | { 94 | // Free the memory 95 | mLastBitmap.recycle(); 96 | mLastBitmap = null; 97 | } 98 | mLastBitmap = remoteBitmap; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/java/com/newtronlabs/smconsumerdemo/RemoteBitmapTask.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.smconsumerdemo; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.os.AsyncTask; 7 | 8 | import com.newtronlabs.sharedmemory.IRemoteSharedMemory; 9 | import com.newtronlabs.sharedmemory.RemoteMemoryAdapter; 10 | 11 | import java.io.IOException; 12 | import java.lang.ref.WeakReference; 13 | 14 | /** 15 | * Helper task for reading a bitmap from a Shared Memory region. 16 | * In order for the bitmap to be loaded the Remote application must have: 17 | * 1 - Allocated a Shared Memory region. 18 | * 2- Written a bitmap to that region. 19 | */ 20 | public class RemoteBitmapTask extends AsyncTask 21 | { 22 | 23 | /** 24 | * Listener that will be notified when the Bitmap retrieval is done. 25 | */ 26 | public interface OnRemoteBitmapListener 27 | { 28 | /** 29 | * Called when the Bitmap retrieval is done. 30 | * @param remoteBitmap Bitmap retrieved from the remote app, null if the image could not be read. 31 | * @param producerAppId Application ID of the remote application whose memory we tried to access. 32 | * @param regionName Name of the region we tried to access on the remote application. 33 | */ 34 | void onBitmapRetrieved(Bitmap remoteBitmap, String producerAppId, String regionName); 35 | } 36 | 37 | //Application ID of the Android application that shared the memory. 38 | private final String mProducerAppId; 39 | 40 | //Name of the Shared Region as created by the remote producer app. 41 | private final String mRegionName; 42 | 43 | private Context mContext; 44 | 45 | private WeakReference mListener; 46 | 47 | public RemoteBitmapTask(Context context, String producerAppId, String regionName, OnRemoteBitmapListener listener) 48 | { 49 | mContext = context.getApplicationContext(); 50 | mProducerAppId = producerAppId; 51 | mRegionName = regionName; 52 | mListener = new WeakReference(listener); 53 | 54 | } 55 | @Override 56 | protected Bitmap doInBackground(Void... voids) 57 | { 58 | // Try to access the memory from the remote application. 59 | // Note: The remote application must have allocated a memory region with the same 60 | // name or this call will fail and return null. 61 | IRemoteSharedMemory remoteMemory = RemoteMemoryAdapter.getDefaultAdapter() 62 | .getSharedMemory(mContext, mProducerAppId, mRegionName); 63 | 64 | if(remoteMemory == null) 65 | { 66 | // Failed to access shared memory. 67 | return null; 68 | } 69 | 70 | // Allocate memory to read the bitmap. 71 | byte[] bitmapBytes = new byte[remoteMemory.getSize()]; 72 | 73 | Bitmap remoteBitmap = null; 74 | 75 | try 76 | { 77 | // Read the remote memory. 78 | remoteMemory.readBytes(bitmapBytes, 0, 0, bitmapBytes.length); 79 | remoteBitmap = BitmapFactory.decodeByteArray(bitmapBytes, 0, bitmapBytes.length); 80 | // Close the reference we don't need it anymore. 81 | remoteMemory.close(); 82 | } 83 | catch (IOException e) 84 | { 85 | e.printStackTrace(); 86 | } 87 | 88 | 89 | 90 | return remoteBitmap; 91 | } 92 | 93 | @Override 94 | protected void onPostExecute(Bitmap bitmap) 95 | { 96 | super.onPostExecute(bitmap); 97 | 98 | OnRemoteBitmapListener listener = mListener.get(); 99 | 100 | if(listener == null) 101 | { 102 | return; 103 | } 104 | 105 | listener.onBitmapRetrieved(bitmap, mProducerAppId, mRegionName ); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/drawable/image_holder_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 18 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 29 | 30 | 39 | 40 | 50 | 51 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #fff05f40 4 | #fff05f40 5 | #FFFFFFFF 6 | 7 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 16dp 7 | 32dp 8 | 9 | 1dip 10 | 10dip 11 | 12 | 200dip 13 | 14 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Sm-Consumer 3 | Shared Memory - Consumer 4 | 5 | About 6 | 7 | The Newtron Labs Shared Memory library allows your 8 | apps to overcome the Android IPC limitation of 1MB by letting apps share 9 | a region in memory they can all read from and write to. 10 | 11 | Tap to Load Remote Bitmap 12 | Unable to read remote memory. Verify the producer app is installed and has allocated a shared memory region. 13 | 14 | -------------------------------------------------------------------------------- /SmConsumer/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 19 | 20 | 21 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /SmConsumer/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" } 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:3.5.2' 8 | classpath "com.newtronlabs.android:plugin:3.0.0" 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" } 16 | } 17 | } 18 | 19 | subprojects { 20 | apply plugin: 'com.newtronlabs.android' 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /SmConsumer/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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /SmConsumer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmConsumer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /SmConsumer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Nov 07 18:09:08 EST 2017 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-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /SmConsumer/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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /SmConsumer/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 | -------------------------------------------------------------------------------- /SmConsumer/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /SmProducer/.gitignore: -------------------------------------------------------------------------------- 1 | *.apk 2 | *.ap_ 3 | *.dex 4 | *.class 5 | bin/ 6 | gen/ 7 | out/ 8 | .gradle/ 9 | build/ 10 | local.properties 11 | proguard/ 12 | *.log 13 | .navigation/ 14 | captures/ 15 | *.iml 16 | .idea/workspace.xml 17 | .idea/tasks.xml 18 | .idea/gradle.xml 19 | .idea/dictionaries 20 | .idea/libraries 21 | *.jks 22 | .externalNativeBuild 23 | google-services.json 24 | freeline.py 25 | freeline/ 26 | freeline_project_description.json.externalNativeBuild 27 | -------------------------------------------------------------------------------- /SmProducer/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SmProducer/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /SmProducer/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | -------------------------------------------------------------------------------- /SmProducer/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SmProducer/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /SmProducer/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /SmProducer/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.newtronlabs.smproducerdemo" 8 | minSdkVersion 13 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:25.2.0' 24 | 25 | // Shared Memory Library 26 | provided 'com.newtronlabs.sharedmemory:sharedmemory:3.0.0' 27 | } 28 | -------------------------------------------------------------------------------- /SmProducer/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SmProducer/app/src/main/java/com/newtronlabs/smproducerdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.smproducerdemo; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.newtronlabs.sharedmemory.SharedMemoryProducer; 11 | import com.newtronlabs.sharedmemory.prod.memory.ISharedMemory; 12 | 13 | import java.io.IOException; 14 | 15 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, ShareBitmapTask.OnProducedBitmapListener 16 | { 17 | /** 18 | * Sample: Name of the Shared Memory to allocate so that other applications 19 | * can access it. 20 | */ 21 | private static final String mRegionName = "Test-Region"; 22 | 23 | private ISharedMemory mLocalMemory; 24 | private ImageView mImageView; 25 | private TextView mMessageView; 26 | private Bitmap mSharedBitmap; 27 | private View mContentHolder; 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) 31 | { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | 35 | mImageView = (ImageView)findViewById(R.id.img_remote); 36 | mMessageView = (TextView)findViewById(R.id.tv_message); 37 | 38 | mContentHolder = findViewById(R.id.content_holder); 39 | mContentHolder.setOnClickListener(this); 40 | 41 | View closeBtn = findViewById(R.id.btn_destroy); 42 | closeBtn.setOnClickListener(this); 43 | 44 | Object savedState = getLastCustomNonConfigurationInstance(); 45 | if(savedState instanceof ISharedMemory) 46 | { 47 | // Reuse the shared memory reference. 48 | mLocalMemory = (ISharedMemory)savedState; 49 | } 50 | } 51 | 52 | @Override 53 | public Object onRetainCustomNonConfigurationInstance() 54 | { 55 | // Preserve the shared memory reference across the activity config change. 56 | return mLocalMemory; 57 | } 58 | 59 | @Override 60 | public void onClick(View view) 61 | { 62 | if(view.getId() == R.id.content_holder) 63 | { 64 | /** 65 | * Allocate a region of memory that can be accessed by other processes 66 | * and applications. 67 | */ 68 | if(mLocalMemory != null) 69 | { 70 | mLocalMemory.close(); 71 | } 72 | 73 | // Allocate 2MB. 74 | int sizeInBytes = 2*(1024*1024); 75 | try 76 | { 77 | mLocalMemory = SharedMemoryProducer.getInstance().allocate(mRegionName, sizeInBytes); 78 | ShareBitmapTask task = new ShareBitmapTask(this, R.drawable.newtron, mLocalMemory, this); 79 | task.execute(); 80 | } 81 | catch (IOException e) 82 | { 83 | handleErrorCase(); 84 | } 85 | } 86 | else if(view.getId() == R.id.btn_destroy) 87 | { 88 | if(mLocalMemory != null) 89 | { 90 | /** 91 | * Release the shared memory. 92 | * From this point on any attempt by a remote application to read or 93 | * write will fail with a IOException. 94 | */ 95 | mLocalMemory.close(); 96 | mLocalMemory = null; 97 | } 98 | 99 | mMessageView.setText(R.string.usage_message); 100 | mMessageView.setVisibility(View.VISIBLE); 101 | mImageView.setImageBitmap(null); 102 | mImageView.setVisibility(View.GONE); 103 | if(mSharedBitmap != null && !mSharedBitmap.isRecycled()) 104 | { 105 | mSharedBitmap.recycle(); 106 | mSharedBitmap = null; 107 | } 108 | } 109 | } 110 | 111 | /** 112 | * Helper method to handle the management of the UI 113 | * on error. 114 | */ 115 | private void handleErrorCase() 116 | { 117 | mMessageView.setText(R.string.usage_message_failed); 118 | mImageView.setVisibility(View.GONE); 119 | mMessageView.setVisibility(View.VISIBLE); 120 | } 121 | 122 | @Override 123 | public void onBitmapPreload(ISharedMemory sharedMemory) 124 | { 125 | mMessageView.setText(R.string.usage_message_loading); 126 | mContentHolder.invalidate(); 127 | } 128 | 129 | @Override 130 | public void onBitmapProduced(Bitmap producedBitmap, ISharedMemory sharedMemory) 131 | { 132 | if(producedBitmap == null) 133 | { 134 | handleErrorCase(); 135 | } 136 | else 137 | { 138 | // Display the bitmap. 139 | mImageView.setImageBitmap(producedBitmap); 140 | mMessageView.setVisibility(View.GONE); 141 | mImageView.setVisibility(View.VISIBLE); 142 | 143 | mSharedBitmap = producedBitmap; 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /SmProducer/app/src/main/java/com/newtronlabs/smproducerdemo/ShareBitmapTask.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.smproducerdemo; 2 | 3 | 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.os.AsyncTask; 8 | import android.support.annotation.DrawableRes; 9 | import android.util.Log; 10 | 11 | import com.newtronlabs.sharedmemory.prod.memory.ISharedMemory; 12 | 13 | import java.io.ByteArrayOutputStream; 14 | import java.io.IOException; 15 | import java.lang.ref.WeakReference; 16 | 17 | public class ShareBitmapTask extends AsyncTask 18 | { 19 | /** 20 | * Listener that will be notified when the Bitmap is loaded and 21 | * written to the Shared Memory region. 22 | */ 23 | public interface OnProducedBitmapListener 24 | { 25 | /** 26 | * Called prior to the start of the loading process. 27 | * @param sharedMemory 28 | */ 29 | void onBitmapPreload(ISharedMemory sharedMemory); 30 | /** 31 | * Called when the bitmap alloaction process is done. 32 | * @param producedBitmap Bitmap that was loaded into the Shared Memory region, or null on error. 33 | * @param sharedMemory Shared Memory region where the bitmap was written to. 34 | */ 35 | void onBitmapProduced(Bitmap producedBitmap, ISharedMemory sharedMemory); 36 | } 37 | 38 | private Context mContext; 39 | private @DrawableRes int mBitmapRes; 40 | private ISharedMemory mSharedRegion; 41 | private WeakReference mListener; 42 | 43 | public ShareBitmapTask(Context context, @DrawableRes int bitmapRes, ISharedMemory memoryRegion, OnProducedBitmapListener listener) 44 | { 45 | mContext = context.getApplicationContext(); 46 | mBitmapRes = bitmapRes; 47 | mSharedRegion = memoryRegion; 48 | mListener = new WeakReference(listener); 49 | } 50 | 51 | @Override 52 | protected void onPreExecute() 53 | { 54 | super.onPreExecute(); 55 | 56 | OnProducedBitmapListener listener = mListener.get(); 57 | 58 | if(listener!= null) 59 | { 60 | listener.onBitmapPreload(mSharedRegion); 61 | } 62 | } 63 | 64 | @Override 65 | protected Bitmap doInBackground(Void... voids) 66 | { 67 | 68 | if(mSharedRegion == null) 69 | { 70 | return null; 71 | } 72 | 73 | Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), mBitmapRes); 74 | 75 | if(bm == null) 76 | { 77 | Log.e("Sm-Producer", "Bitmap factory failed to load Bitmap. Image too large."); 78 | return null; 79 | } 80 | 81 | 82 | ByteArrayOutputStream stream = new ByteArrayOutputStream(); 83 | bm.compress(Bitmap.CompressFormat.PNG, 100, stream); 84 | byte[] bmBytes = stream.toByteArray(); 85 | 86 | Bitmap producedBitmap = null; 87 | 88 | try 89 | { 90 | // Copy the Bitmap to the Shared Memory region to make it accessible to 91 | // other processes or applications. 92 | mSharedRegion.writeBytes(bmBytes, 0, 0, bmBytes.length); 93 | producedBitmap = bm; 94 | 95 | } 96 | catch (IOException e) 97 | { 98 | e.printStackTrace(); 99 | } 100 | return producedBitmap; 101 | } 102 | 103 | @Override 104 | protected void onPostExecute(Bitmap bitmap) 105 | { 106 | super.onPostExecute(bitmap); 107 | 108 | OnProducedBitmapListener listener = mListener.get(); 109 | 110 | if(listener == null) 111 | { 112 | return; 113 | } 114 | 115 | listener.onBitmapProduced(bitmap, mSharedRegion); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /SmProducer/app/src/main/res/drawable/image_holder_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 18 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SmProducer/app/src/main/res/drawable/newtron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/SharedMemory/aeec851b618b4b45bbe82221ef12ee35b9513f9a/SmProducer/app/src/main/res/drawable/newtron.png -------------------------------------------------------------------------------- /SmProducer/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 29 | 30 | 39 | 40 | 50 | 51 | 58 | 59 | 60 | 61 |