Shared Memory


Source link: https://github.com/NewtronLabs/SharedMemory

Shared Memory

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.


How to Use

Setup

Include the below dependencies in your build.gradle project.

buildscript {

  repositories {

jcenter()

maven {
 url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" 
}

  
}

  dependencies {

classpath 'com.android.tools.build:gradle:2.3.3'

classpath "com.newtronlabs.android:plugin:1.1.0"
  
}
 
}
  allprojects {

  repositories {

jcenter()

maven {
 url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" 
}

  
}
 
}
  subprojects {

  apply plugin: 'com.newtronlabs.android' 
}

In the build.gradle for your app.

dependencies {

  provided 'com.newtronlabs.sharedmemory:sharedmemory:2.0.0' 
}

Sharing Memory - Producer

From the application that wishes to shared its memory, allocate a shated memory region with a given name.

// Allocate 2MB int sizeInBytes = 2*(1024*1024);
 String regionName = "Test-Region"; ISharedMemory sharedMemory = SharedMemoryProducer.getInstance().allocate(regionName, sizeInBytes);

Write data to memory:

byte[] strBytes = "Hello World!".getBytes();
 sharedMemory.writeBytes(strBytes, 0, 0, strBytes.length);

Once an application has shared a memory region it can be accessed by other processes or application which are aware of it.

Accessing Shared Memory - Consumer

In order for an application to access a region of memory shaered by an external application perform the following:

// This is the application id of the application or process which shared the region. String producerAppId = "com.newtronlabs.smproducerdemo";  // Name under wich the remote region was created. String regionName = "Test-Region"  // Note: The remote application must have allocated a memory region with the same //

 name or this call will fail and return null. IRemoteSharedMemory remoteMemory

  = RemoteMemoryAdapter.getDefaultAdapter().getSharedMemory(context, producerAppId, regionName);
  // Allocate memory to read shared content. byte[] dataBytes = new byte[remoteMemory.getSize()]; String dataStr = new String(dataBytes);
 Log.d("Newtron", "Memory Read:"+dataStr);

Additional Samples

A set of more complex exmaples can be found in this repo's samples folders: SmProducer and SmConsumer.


License

Shared Memory binaries and source code can only be used in accordance with Freeware license. That is, freeware may be used without payment, but may not be modified. The developer of Shared Memory retains all rights to change, alter, adapt, and/or distribute the software. Shared Memory is not liable for any damages and/or losses incurred during the use of Shared Memory.

You may not decompile, reverse engineer, pull apart, or otherwise attempt to dissect the source code, algorithm, technique or other information from the binary code of Shared Memory unless it is authorized by existing applicable law and only to the extent authorized by such law. In the event that such a law applies, user may only attempt the foregoing if: (1) user has contacted Newtron Labs to request such information and Newtron Labs has failed to respond in a reasonable time, or (2) reverse engineering is strictly necessary to obtain such information and Newtron Labs has failed to reply. Any information obtained by user from Newtron Labs may be used only in accordance to the terms agreed upon by Newtron Labs and in adherence to Newtron Labs confidentiality policy. Such information supplied by Newtron Labs and received by user shall not be disclosed to a third party or used to create a software substantially similar to the technique or expression of the Newtron Labs Shared Memory software.

You are solely responsible for determining the appropriateness of using Shared Memory and assume any risks associated with Your use of Shared Memory. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall Newtron Labs be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Shared Memory (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if Newtron Labs has been advised of the possibility of such damages.

Patent Pending

Contact

[email protected]

Resources

Add some Depth to your fragments.

An android library that wraps the ExoPlayer and the IMA Android SDK which plays a video advertisement. This is written in Kotlin.

Change Android launcher App Icon and App Name programmatically.

A Twitter style post length counter which can be bound to an EditText and provide callbacks when hitting a max character count.

Once bound to an EditText the characters remaining will go down as the user types. If the user goes over the max limit you will get notified and the view will show how much they are over.

FlowR is a wrapper class around the Fragment Manager. It's mainly used to navigate between different fragments easily while providing a wide range of functionality. The following are the functionalities provided by the Flowr:

Easily navigate between different fragments. Ability to open fragments for result. Keeping the state of the activity correctly synced depending on the custom values specified by the fragment currently visible such as the screen orientation and navigation bar colour.

Sliding Tab Layout with color icons.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes