I want to know exact ,
parcelable
or serialization
technique
for sending data from one activity to other?Thanks in advance.
public class GetSetClass implements Serializable {
private int dt = 10;
/** pass any object, drwabale */
public int getDt() {
return dt;
}
public void setDt(int dt) {
this.dt = dt;
}
}
These concepts are related to Inter Process Communication (IPC).
When sending data between two applications, we have to make sure that both applications should understand the format of the data that is being sent.
Especially when you are sending non primitive data type values like classes and objects between two applications, We have to convert them into Operating System understandable format. O.S understands only primitive types (ints, chars etc). The reason for conversion is we have to O.S communication channel to transmit the data.
This process of converting Non primitive types to primitives and sending across to other application over some communication channel is called as Serialization. The reverse process is called as De Serialization.
In Java, IPC depends heavily on Serializables for serialization. But serialization is designed by keep desktop applications in mind. When you are doing IPC in mobile applications we have to make sure that the process of IPC is not too heavy.
In simple terms serialization is a heavy concept for IPC. So in place of Serialization Android opted for Binders for achieving light weight Inter process communication. Binders internally depends heavily on parcels, to do the IPC. Parcels are light weight serializables. It is preferred to use parcels for marshaling objects into byte streams.
Note: Binder IPC heavily depends on Shared memory concept to make sure that there is not much data duplication while sharing between applications.