Normally a new activity runs in the same process (that is the default). So you can simply call a member function of NewProcessActivity
from activity AndroidProcessActivity
and vice-versa.
For example you can use a singleton variable inside NewProcessActivity
so you have an object when you want to call a member function. But be aware activities can be launched multiple times.
There is the process and multiprocess property of <activity>
. Those might result in an activity being run on a separate process.
Because everything (also threads) are called processes on Linux I am not sure if it's possible to simply call methods on this new process from the main process. I recommand to simply try it out and if it works you have to use Java synchronized to make everything thread safe.
If it's not possible (that is what I expect) you have to use IPC:
- use the start
Intent
to pass parameters to the activity
- use broadcasts to send messages in both directions (do this if you have to transfer simple values only)
- If you have a complicated API you have to create your own service and bind it (see bound services). You have to write an .aidl file. This is how IPC is normally done on Android.
- If you have native code or you want max. performance you can do native Linux IPC. Those could be local sockets or shared memory for example. But this might require root and it's unusual.