Recipe Sharing a Thread Between Two Applications

The previous recipes motivated the use of multiple threads in a single application.The converse case is also sometimes useful: use of multiple applications in a single thread. For example, if two applications need to communicate between each other, they can do so using binders rather than the more complicated inter-process communication (IPC) pro-tocol.The steps are

1. Make sure each application, when packaged for release, is signed with the same key for security reasons.

2. Make sure each application is run with the same user ID. This is done by declaring the same attribute android:sharedUserId="my.shared.userid" in the ActivityManifest.xml for each application.

3. Declare each relevant activity or component to be run in the same process.This is done by declaring the same attribute android:process="my.shared.process-name" in the ActivityManifest.xml for each component.

These simple steps ensure the two components are run in the same thread and transparently share the same information. The more complex case where permissions cannot be shared is covered in the "Implementing a Remote Procedure Call" recipe in Chapter 11, "Advanced Android Development."

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook


Post a comment