整理通知包裹

编程入门 行业动态 更新时间:2024-10-12 03:20:42
本文介绍了整理通知包裹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将Notification对象写入文件. 我能找到的最好方法是将对象写入一个包裹,将其封送以获取字节[],然后将其写入文件.

I'm trying to write a Notification object to a File. The best way I could find was to write the object to a parcel, marshall that parcel to get a byte[] and then write it to a file.

Parcel notif = Parcel.obtain(); notification.writeToParcel(notif, 0); byte[] notifArray = notif.marshall();

我尝试封送包裹时遇到运行时异常: 试图封送一个包含活页夹对象的包裹."

I get a Runtime exception when I try to marshall the parcel though: "Tried to marshall a Parcel that contained Binder objects."

是否有更好的方法将Notification对象写入文件?否则,我该如何使用这种方法?

Is there a better way of writing Notification objects to file? Else, how do I get this approach to work?

推荐答案

该通知包含一个活动/活动活页夹对象.它不是为了用于保存状态(以byte []形式)而是为了IPC的目的而实现了Parcelable.理想情况下,您应该保存必要的字段,而不是对象本身.

The notification contains a live/active binder object. It wasn't built to be used for saving the state (in a byte[]) rather it implements Parcelable for IPC purposes. You should ideally save the necessary fields rather than the object itself.

更多推荐

整理通知包裹

本文发布于:2023-11-27 14:58:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638538.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包裹   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!