在Android系统中会给每个进程分配独立的内存空间,不同内存空间是不能互相访问的。因此,进程间的通信就会麻烦一点。SDK中提供了4种方式。
一、Intent
Intent是用于实现组件之间的通信。有两种使用方式:
显式调用(主要用于本应用内组件的启动和通信)
Intent intent = new Intent(this,MainActivity.class);
startActivity(intent);
隐式调用(可用于跨进程通信)
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
startactvity(intent);
二、Content Provider
ContentProvider主要用于对外提供数据,其他应用通过它实现对应用种的数据增、删、改、查
三、Broadcast Receiver
四、AIDL