- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
使用 Protocol Buffer 对象(序列化为字节数组)在 Android Activity 之间作为 intent extras 传递而不是在经典 POJO 上实现 Parcelable 是个好主意吗?它将如何影响性能?
谢谢马库斯
最佳答案
要确定您必须针对您的特定情况进行测试。
关于 Parcel 的注意事项:
您可能知道,这是一个手动过程:您必须遍历对象树并调用 Parcel 的各种序列化方法,例如writeFloatArray(..)
。没有魔法,它是最底层的。
Parcel.java 是 native 实现的包装器,因此它应该已经非常优化:http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/libs/binder/Parcel.cpp&q=Parcel.cpp%20package:android&sa=N&cd=1&ct=rc
不要使用 Binder,因为它会创建一个代理(如果跨进程)。
可能最重要的是:使用 setDataCapacity(int size)
正确调整初始缓冲区的大小。这样内部数组就不需要增长(= 内存分配 + 复制)。
如果您多次使用 Parcel,则使用 recycle()
将其还给池。
关于android - 在 Android intent extras 中使用 protobuffers 而不是 Parcelables?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6028369/
我正在将 ansible 合并到我们的内部 RHN 卫星中。我有来自 Red Hat 的完全更新的 RHEL 7 基础 repo 、附加、补充、可选和 RHN 工具。当我们需要它们时,我还会将选定的包
我尝试将一些值发送到另一个 Activity 。 recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicatio
我有这个代码: Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.s
几天前,我一直在努力寻找一种方法来为我的闹钟使用自定义 Intent 。虽然我得到了明确的答案,但我必须根据一些唯一的 ID 来定制 Intent,例如。 setAction()还是有一些问题。 我这
通知正在提供旧值。我阅读了 stackoverflow 链接,但仍然不适合我: Notification passes old Intent Extras 我有一个 Activity A。当我在 Ac
我想写以下内容: result = [] for x in list(range(10)): if x%2 != 0: for a in [1,2]:
我在使用 mysql 5.5.12 时遇到了 Amazon RDS 的 IO 性能问题。有 2 种实例类型相似且价格接近: 超大数据库实例:15 GB 内存、8 个 ECU(4 个虚拟核心,每个 2
这里是 Android 的新手,我正在与一位资深人士就 bundle 和 Intent 进行辩论。这就是我一直在做的...... Intent intent = new Intent(this, Ta
我使用的是MinGW+MSYS, 我添加了 extra-include-dirs、extra-lib-dirs,但似乎没有任何东西可以帮助 cabal 找到 PCRE 库。以下是我尝试过的一些命令行,
我已将 CVS 中的一个模块 check out 到新安装的 Windows 7 计算机上。病毒扫描程序尚未安装。 后来,当我尝试进行更新时,收到以下错误消息: 无法将文件 CVS/Entries.E
Alpine镜像中的telnet在3.7版本后被转移至busybox-extras包中,需要使用apk单独安装。 现象 Alpine版本为3.8, 不再有指向busybox的telent
对lazy="extra"究竟能做什么,有没有很好的解释? 我看过的所有帖子都只是重复了一个事实,即它会引用 MyObject.ItsCollection.Count进入 select count(*
这个问题已经有答案了: Two semicolons inside a for-loop parentheses (4 个回答) Endless loop in C/C++ [closed] (12
我的包为包含的额外内容返回空字符串。不是 NPE,是实际的“空”值。关于为什么会发生这种情况的任何想法? 新 bundle String u = nul
在 es6 中,以下似乎是有效代码: function test(a1,{a=1,b=2} = {},) {} 注意函数参数中额外的,。我不确定这是否是一个错误,因为这个额外的 , 仅适用于解构分配。
我正在查看一个包含 .myClass a.extra{...} 和 .myClass a.extra:hover{...} 的 css 模板“额外”是什么意思? 最佳答案 extra 是类名。 因为你
我来自 Web 开发的前端世界,我们非常努力地尝试限制发出的 HTTP 请求的数量(通过合并 css、js 文件、图像等)。 对于数据库连接 (MySQL),显然您不希望有不必要的连接,但作为一般规则
问题是关于包含不必要的 header 以避免在子文件中多次调用它。这是场景,我有几个文件: srlogger.h srinterface.h srinterface.cc #include #inc
我有一个程序表现出奇怪的行为 #include #include using namespace std; class man{ int i ; public:
本文整理了Java中org.threeten.extra.YearQuarter类的一些代码示例,展示了YearQuarter类的具体用法。这些代码示例主要来源于Github/Stackoverflo
我是一名优秀的程序员,十分优秀!