I want to run two processes in the same DalvikVM. This means that I want to run a first app and then that this app starts the second app. And I want that this two apps are then running in the same DalvikVM. I think it is possible if the first app forks an process for the second app. But I´m not sure how can I do that. Thanks
-
1I am curious, what was the reason to want this. – Alex Cohn Oct 02 '14 at 17:58
2 Answers
I very much doubt what you actually want to do is go digging into the specifics of processes (if you do I would question why). In any case, Android deliberately makes it very difficult for you to go near processes as the platform provides sufficient mechanisms to achieve virtually any functional flow without needing to.
I suspect what you actually mean is you need to start a new Android task (has it's own back stack, functionally operates like a separate application).
Have a read of the Tasks and Back Stack document from the dev guide, particularly the section on tasks. What you probably want to look at is starting your new activity using the FLAG_ACTIVITY_NEW_TASK flag in the Intent
.

- 3,373
- 1
- 25
- 33
-
Thanks but I really wanted to do it and I dont understand why it should be inpossible to say the zygote to fork a new process but with the same dalvikvm – Aprel Jan 28 '12 at 19:42
-
1@Aprel - you can in fact get zygote to give you a different process for an Activity or a Service if you specify that it should have one in your AndroidManifest, or you can get the underlying Linux to clone your existing process (at least for limited non-Android purposes). But the other process will contain a *distinct* VM *with its own state*, rather than "the same one". They can still talk, however through interprocess communication such as an AIDL-style service connection. – Chris Stratton Oct 02 '14 at 14:48
I want to run two processes in the same DalvikVM.
By definition, that is impossible.
This means that I want to run a first app and then that this app starts the second app. And I want that this two apps are then running in the same DalvikVM.
By definition, that is impossible.
I think it is possible if the first app forks an process for the second app.
No.

- 986,068
- 189
- 2,389
- 2,491
-
1
-
2@Aprel: A virtual machine can only be in one process. Multiple processes mean multiple virtual machines. – CommonsWare Jan 23 '12 at 13:50
-
But there are many emulators for Android and you can then run games or programms in emulator. This means linux kernel -> Dalvik vm -> Android ->Emulator -> VM --> game. And I wont just to run for example DalvikVm as app over an original dalvikVm – Aprel Feb 05 '12 at 15:36
-
2@Aprel: "But there are many emulators for Android and you can then run games or programms in emulator." -- most of those are not running on Dalvik VM, insofar as they are using the NDK and running native a C/C++ implementation of the emulation environment. – CommonsWare Feb 05 '12 at 15:42
-
Ok Thanks. And there no way to run an emulator or Debian/Ubuntu/some modified Dalvik VM over the Dalvik VM? – Aprel Feb 05 '12 at 20:51
-
These comments have verged into mistaken territory. One can in fact run an emulator on top of the Dalvik VM, or any other turing-complete engine, provided that there is sufficient storage to track the state of the emulation. And one can fork a process off an Android app. **What is correct is that the VM (if any) in the forked process will be a unique instance (rather than "the same" one) as its state will immediately diverge**. It may (?) also not be properly registered with the Android platform through Binder and thus perhaps (?) unable to use Android-level system services. – Chris Stratton Oct 02 '14 at 14:45