在Android系统中, 进程非常重要, 除了 主进程 运行App, 我们还可以使用 其他进程处理独立任务. 更多: http://www.wangchenlong.org/ 欢迎Follow我的GitHub: https://github.com/SpikeKing 进程, 即Process. 进程间通信, 即IPC(Inter-Process Communication).
在Android中, 使用多进程只有一种方式, 在AndroidManifest中, 为四大组件(Activity, Service, Receiver, ContentProvider)指定 <service android:name=".PedometerCounterService" android:exported="false" android:process=":cy_pedometer_set"/>
默认进程的进程名是 包名 . ➜ ~ adb shell ps | grep wangchenlong.chunyu.me.android_pedometer_set u0_a354 28490 410 2259024 80272 ffffffff 00000000 S wangchenlong.chunyu.me.android_pedometer_set u0_a354 28515 410 2191112 60080 ffffffff 00000000 S wangchenlong.chunyu.me.android_pedometer_set:cy_pedometer_set 进程ID是 使用 多进程无法通过内存共享数据. 可以通过 Intent 传递数据. 不同进程的组件会拥有独立的 虚拟机 , Application , 内存空间 . 多个进程, Application会创建多次.
Intent可以使用 |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|