什么是Android的使用Parcelable和系列化的区别区别、Android、Parcelable

2023-09-05 10:01:40 作者:猫九

我想知道确切的,

在是否应该我用 parcelable 序列化技术 发送从一个活动的数据到其他? 是否必须 使用其中一个用于从一个到其他发送数据? 时,应使用它们? ,并将它们与性能之间的确切区别 在Java方面他们两人。

在此先感谢。

 公共类GetSetClass实现Serializable {
    私人诠释DT = 10;

    / **传递任何对象,drwabale * /
    公众诠释getDt(){
        返回DT;
    }

    公共无效setDt(INT DT){
        this.dt = DT;
    }
}
 

解决方案   

是否我应该使用parcelable或序列化技术来发送从一个活动数据等。

如果您通过意图发送一个非基本类型的数据/对象到另一个活动你要么序列化或实施 Parcelable 该对象。在preferred技术是 Parcelable ,因为它不影响性能。

  

是它必须使用它们中的一个用于发送数据从一个到其他。 /我应该在何时使用它们。

这是唯一的强制性/用于发送非基本类型的数据对象。

  海柔 箱式仓储机器人助力3C行业自动化升级

和他们,他们两人在Java方面性能之间准确的区别。

序列确实影响性能。欲了解更多详细信息,请检查该链接的Andr​​oid Parcelable和序列化

I want to know exact ,

whether should I used parcelable or serialization technique for sending data from one activity to other? is it compulsory to use one of them for sending data from one to other? when should I use them? and the exact difference between them and performance of both of them in java aspects.

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;
    }
}

解决方案

whether should i used parcelable or serialization technique for sending data from one activity to other.

If you are sending a non-primitive type data/Object to another activity through the intent you have to either Serialize or implement Parcelable for that object. The preferred technique is Parcelable since it doesn't impact the performance.

is it compulsory to use one of them for sending data from one to other. / when should i use them.

It is only compulsory/used for sending non-primitive type data objects.

and the exact difference between them and performance of both of them in java aspects.

Serialization does impact the performance. For more details check this link Android Parcelable and Serializable