Parcelable遇到IOException编写可序列化对象的原因

时间:2018-07-14 08:13:31

标签: android exception

我在下面的行中调用时得到以下异常

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("some url")))

java.lang.RuntimeException:遇到IOException写入Parserable对象时发生可打包(

logcat显示

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.myh.videoplayer.models.VideoGroup)
        at android.os.Parcel.writeSerializable(Parcel.java:1505)
        at android.os.Parcel.writeValue(Parcel.java:1453)
        at android.os.Parcel.writeArrayMapInternal(Parcel.java:702)
        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1412)
        at android.os.Bundle.writeToParcel(Bundle.java:1133)
        at android.os.Parcel.writeBundle(Parcel.java:742)
        at android.support.v4.app.FragmentState.writeToParcel(FragmentState.java:123)
        at android.os.Parcel.writeTypedArray(Parcel.java:1285)
        at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:619)
        at android.os.Parcel.writeParcelable(Parcel.java:1474)
        at android.os.Parcel.writeValue(Parcel.java:1380)
        at android.os.Parcel.writeArrayMapInternal(Parcel.java:702)
        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1412)
        at android.os.Bundle.writeToParcel(Bundle.java:1133)
        at android.os.Parcel.writeBundle(Parcel.java:742)
        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3629)
        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3974)
        at android.os.Handler.handleCallback(Handler.java:761)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
     Caused by: java.io.NotSerializableException: com.google.android.gms.ads.AdView
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at java.util.ArrayList.writeObject(ArrayList.java:734)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:977)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1536)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)

VideoGroup.java

public class VideoGroup implements Serializable {
    private List<VideoInfo> videoInfoList;
    private String groupName;

    public List<VideoInfo> getVideoInfoList() {
        return videoInfoList;
    }

    public void setVideoInfoList(List<VideoInfo> videoInfoList) {
        this.videoInfoList = videoInfoList;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
}

VideoInfo.java

public class VideoInfo implements Serializable {
    private String title;
    private String path;
    private long size;
    private String thumbPath;
    private int duration;
    private String folderPath;
    private String displayName;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public String getThumbPath() {
        return thumbPath;
    }

    public void setThumbPath(String thumbPath) {
        this.thumbPath = thumbPath;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String getFolderPath() {
        return folderPath;
    }

    public void setFolderPath(String folderPath) {
        this.folderPath = folderPath;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }
}

我进行了大量搜索,发现解决方案建议通过可序列化来实现所描述的原因类,但是我不知道如何通过可序列化来实现adview或是否有任何其他可用的解决方案可以帮助我。 预先感谢您的帮助。

0 个答案:

没有答案