java.lang.RuntimeException: Parcelable encountered IOException writing serializable












0















I have an arraylist that i want to send from 1 activity to another, I am using serializable but end up getting following error message.




java.lang.RuntimeException: Parcelable encountered IOException
writing serializable object (name = com.app...)




I have also reviewed some question regarding this on SO, most of them saying that all classes defined inside your Serialized class should also implement Serializable, but here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes.



This is how i am sending array list from 1 activity to another.



Intent intent= new Intent(MainActivity.this, DetailsActivity.class);
Bundle bundle= new Bundle();
bundle.putSerializable("PATH_LIST", pathsList);
bundle.putString("FILE_NAME", fileName);
intent.putExtras(bundle);
startActivity(intent);


and this is my class.



public class TData implements Serializable {

Matrix originalMatrix;
public Path path;
PointF position;



private TData attachedPathData;
public void setAttachedPathData(TData pathData){
attachedPathData = pathData;
}
public TData getAttachedPathData(){
return attachedPathData;
}


public TData(){

}


public TData(Path path, PointF position, String id, String fillColor, String strokeColor){
this.path = path;
this.position = position;
this.id = id;

this.fillColor = fillColor;
this.strokeColor = strokeColor;
}

public void Scale(float scaleX, float scaleY){
this.scaleX = scaleX;
this.scaleY = scaleY;

Matrix scaleMatrix = new Matrix();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
scaleMatrix.setScale(scaleX,scaleY);
path.transform(scaleMatrix);


Matrix mat = new Matrix();
path.computeBounds(rf, true);

Region r = new Region();

}
}









share|improve this question


















  • 1





    In the future, please post the entire stack trace, not just the error message.

    – CommonsWare
    Nov 24 '18 at 16:10
















0















I have an arraylist that i want to send from 1 activity to another, I am using serializable but end up getting following error message.




java.lang.RuntimeException: Parcelable encountered IOException
writing serializable object (name = com.app...)




I have also reviewed some question regarding this on SO, most of them saying that all classes defined inside your Serialized class should also implement Serializable, but here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes.



This is how i am sending array list from 1 activity to another.



Intent intent= new Intent(MainActivity.this, DetailsActivity.class);
Bundle bundle= new Bundle();
bundle.putSerializable("PATH_LIST", pathsList);
bundle.putString("FILE_NAME", fileName);
intent.putExtras(bundle);
startActivity(intent);


and this is my class.



public class TData implements Serializable {

Matrix originalMatrix;
public Path path;
PointF position;



private TData attachedPathData;
public void setAttachedPathData(TData pathData){
attachedPathData = pathData;
}
public TData getAttachedPathData(){
return attachedPathData;
}


public TData(){

}


public TData(Path path, PointF position, String id, String fillColor, String strokeColor){
this.path = path;
this.position = position;
this.id = id;

this.fillColor = fillColor;
this.strokeColor = strokeColor;
}

public void Scale(float scaleX, float scaleY){
this.scaleX = scaleX;
this.scaleY = scaleY;

Matrix scaleMatrix = new Matrix();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
scaleMatrix.setScale(scaleX,scaleY);
path.transform(scaleMatrix);


Matrix mat = new Matrix();
path.computeBounds(rf, true);

Region r = new Region();

}
}









share|improve this question


















  • 1





    In the future, please post the entire stack trace, not just the error message.

    – CommonsWare
    Nov 24 '18 at 16:10














0












0








0








I have an arraylist that i want to send from 1 activity to another, I am using serializable but end up getting following error message.




java.lang.RuntimeException: Parcelable encountered IOException
writing serializable object (name = com.app...)




I have also reviewed some question regarding this on SO, most of them saying that all classes defined inside your Serialized class should also implement Serializable, but here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes.



This is how i am sending array list from 1 activity to another.



Intent intent= new Intent(MainActivity.this, DetailsActivity.class);
Bundle bundle= new Bundle();
bundle.putSerializable("PATH_LIST", pathsList);
bundle.putString("FILE_NAME", fileName);
intent.putExtras(bundle);
startActivity(intent);


and this is my class.



public class TData implements Serializable {

Matrix originalMatrix;
public Path path;
PointF position;



private TData attachedPathData;
public void setAttachedPathData(TData pathData){
attachedPathData = pathData;
}
public TData getAttachedPathData(){
return attachedPathData;
}


public TData(){

}


public TData(Path path, PointF position, String id, String fillColor, String strokeColor){
this.path = path;
this.position = position;
this.id = id;

this.fillColor = fillColor;
this.strokeColor = strokeColor;
}

public void Scale(float scaleX, float scaleY){
this.scaleX = scaleX;
this.scaleY = scaleY;

Matrix scaleMatrix = new Matrix();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
scaleMatrix.setScale(scaleX,scaleY);
path.transform(scaleMatrix);


Matrix mat = new Matrix();
path.computeBounds(rf, true);

Region r = new Region();

}
}









share|improve this question














I have an arraylist that i want to send from 1 activity to another, I am using serializable but end up getting following error message.




java.lang.RuntimeException: Parcelable encountered IOException
writing serializable object (name = com.app...)




I have also reviewed some question regarding this on SO, most of them saying that all classes defined inside your Serialized class should also implement Serializable, but here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes.



This is how i am sending array list from 1 activity to another.



Intent intent= new Intent(MainActivity.this, DetailsActivity.class);
Bundle bundle= new Bundle();
bundle.putSerializable("PATH_LIST", pathsList);
bundle.putString("FILE_NAME", fileName);
intent.putExtras(bundle);
startActivity(intent);


and this is my class.



public class TData implements Serializable {

Matrix originalMatrix;
public Path path;
PointF position;



private TData attachedPathData;
public void setAttachedPathData(TData pathData){
attachedPathData = pathData;
}
public TData getAttachedPathData(){
return attachedPathData;
}


public TData(){

}


public TData(Path path, PointF position, String id, String fillColor, String strokeColor){
this.path = path;
this.position = position;
this.id = id;

this.fillColor = fillColor;
this.strokeColor = strokeColor;
}

public void Scale(float scaleX, float scaleY){
this.scaleX = scaleX;
this.scaleY = scaleY;

Matrix scaleMatrix = new Matrix();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
scaleMatrix.setScale(scaleX,scaleY);
path.transform(scaleMatrix);


Matrix mat = new Matrix();
path.computeBounds(rf, true);

Region r = new Region();

}
}






android android-intent serializable android-bundle






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 15:41









Kirmani88Kirmani88

1,17172059




1,17172059








  • 1





    In the future, please post the entire stack trace, not just the error message.

    – CommonsWare
    Nov 24 '18 at 16:10














  • 1





    In the future, please post the entire stack trace, not just the error message.

    – CommonsWare
    Nov 24 '18 at 16:10








1




1





In the future, please post the entire stack trace, not just the error message.

– CommonsWare
Nov 24 '18 at 16:10





In the future, please post the entire stack trace, not just the error message.

– CommonsWare
Nov 24 '18 at 16:10












1 Answer
1






active

oldest

votes


















2















here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes..




Then do not have fields for them in Serializable classes.



Either:




  • Do not have separate activities here, but do something else instead (e.g., one activity and two fragments) that avoids the need for the Intent, or


  • Do not pass this data between the activities, but instead use a different application architecture (e.g., the data is not held by either activity, but instead is held by a repository that both activities can talk to), or


  • Create some data structure that you can make Parceable or Serializable, from which you can rebuild your model objects with their desired classes, and pass that Parcelable/Serializable data structure in the Intent instead of TData







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459746%2fjava-lang-runtimeexception-parcelable-encountered-ioexception-writing-serializa%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2















    here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes..




    Then do not have fields for them in Serializable classes.



    Either:




    • Do not have separate activities here, but do something else instead (e.g., one activity and two fragments) that avoids the need for the Intent, or


    • Do not pass this data between the activities, but instead use a different application architecture (e.g., the data is not held by either activity, but instead is held by a repository that both activities can talk to), or


    • Create some data structure that you can make Parceable or Serializable, from which you can rebuild your model objects with their desired classes, and pass that Parcelable/Serializable data structure in the Intent instead of TData







    share|improve this answer




























      2















      here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes..




      Then do not have fields for them in Serializable classes.



      Either:




      • Do not have separate activities here, but do something else instead (e.g., one activity and two fragments) that avoids the need for the Intent, or


      • Do not pass this data between the activities, but instead use a different application architecture (e.g., the data is not held by either activity, but instead is held by a repository that both activities can talk to), or


      • Create some data structure that you can make Parceable or Serializable, from which you can rebuild your model objects with their desired classes, and pass that Parcelable/Serializable data structure in the Intent instead of TData







      share|improve this answer


























        2












        2








        2








        here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes..




        Then do not have fields for them in Serializable classes.



        Either:




        • Do not have separate activities here, but do something else instead (e.g., one activity and two fragments) that avoids the need for the Intent, or


        • Do not pass this data between the activities, but instead use a different application architecture (e.g., the data is not held by either activity, but instead is held by a repository that both activities can talk to), or


        • Create some data structure that you can make Parceable or Serializable, from which you can rebuild your model objects with their desired classes, and pass that Parcelable/Serializable data structure in the Intent instead of TData







        share|improve this answer














        here Path, 'RectF', Matrix, are not my classes, they are android classes, and i can't implement Serializable in these classes..




        Then do not have fields for them in Serializable classes.



        Either:




        • Do not have separate activities here, but do something else instead (e.g., one activity and two fragments) that avoids the need for the Intent, or


        • Do not pass this data between the activities, but instead use a different application architecture (e.g., the data is not held by either activity, but instead is held by a repository that both activities can talk to), or


        • Create some data structure that you can make Parceable or Serializable, from which you can rebuild your model objects with their desired classes, and pass that Parcelable/Serializable data structure in the Intent instead of TData








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 16:11









        CommonsWareCommonsWare

        767k13818721922




        767k13818721922






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459746%2fjava-lang-runtimeexception-parcelable-encountered-ioexception-writing-serializa%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)