IPC: Inter-Process Communication进程间通信。

1.在Android中使用多进程的方法:在四大组件的AndroidManifest中指定android:process属性

                                                                                                        android:process=":remote"/>                       android:process="com.example.suwei.hhh"/>

现在打开MainActivity--SecondActivity--ThirdActivity, 输入 adb shell ps | grep com.example.suwei 查看包名为com.example.suwei的进程:

(未指定process的Activity的默认进程名为包名com.example.suwei.mytest)

 注:进程名以“:”开头的进程属于当前应用的私有进程,其它应用的组件不可以和它跑在同一个进程中,而进程名不以“:”开头的进程属于全局进程,其他应用可以通过ShareUID方式和它跑在同一个进程中。

在多进程模式中,不同进程的组件拥有独立的虚拟机,Application和内存空间。

2.Parcelable接口

public class User implements Parcelable {    public int userId;    public String userName;    public boolean isMale;    public User(int userId,String userName,boolean isMale){        this.userName = userName;        this.userId = userId;        this.isMale = isMale;    }    public int describeContents(){        return 0;    }    public void writeToParcel(Parcel out,int flags){        out.writeInt(userId);        out.writeString(userName);        out.writeInt(isMale ? 1 : 0);    }    public static final Parcelable.Creator CREATOR = new Parcelable.Creator(){        @Override        public User createFromParcel(Parcel source) {            return new User(source);        }        @Override        public User[] newArray(int size) {            return new User[size];        }    };    private User(Parcel in){        userId = in.readInt();        userName = in.readString();        isMale = in.readInt() == 1;    }}

 

转载于:https://www.cnblogs.com/whysu/p/6951300.html

更多相关文章

  1. Android(安卓)开源组件和第三方库汇总
  2. TextView 在xml文件中的解释 android
  3. [android]组件之一Activity简介
  4. android view getWidth 和 getHeight 的值为0
  5. Android(安卓)使用 AIDL 实现进程间通信,使用基本类型作为输入和
  6. Android(安卓)Binder 机制初步学习 笔记(三)—— Binder 进程通讯
  7. android 核心组件( 1 ) 常用布局, adapter, handler, UI
  8. android root权限相关bin程序rageagainsttheca
  9. Android(安卓)SystemService类注释

随机推荐

  1. Nodejs中利用phantom把html转为pdf或图片
  2. 图标旋转但返回上一个位置
  3. CSS定位属性之间的相互作用
  4. 动画滚动无法在Firefox中运行?
  5. HTML5 Canvas编写五彩连珠(3):设计
  6. HTML:关于a标签的target属性
  7. 当锚标记被单击时,角值从一个页面传递到另
  8. jQuery .load停止嵌入页面/重新加载整个
  9. “/图标。ico " vs
  10. 我无法理解为什么我的代码中的单击选择文