gpt4 book ai didi

java - 如何传递 XML Document 对象?

转载 作者:行者123 更新时间:2023-12-01 15:55:33 26 4
gpt4 key购买 nike

是否可以使用 Intent 将 XML DOM 文档传递到另一个线程?我想知道这是否可能,因为我在 Google 上找不到任何相关信息...

我在应用程序中使用不同的 XML 文档,所有这些文档均派生自单个 Interface 类。我想在服务中创建这样的文档,然后将其传递给线程或另一个服务以通过 DatagramSocket 发送它。但我不知道如何正确地做到这一点...我想可以使文档可序列化,然后将它们添加到我想要传递的 Intent 中...但这是否是正确的方法或者是使用另一种方法更好吗?

最佳答案

Is it possible to pass around an XML DOM Document to another Thread using an Intent?

首先,您不会通过 Intents 将内容传递给线程,除非该线程是由 IntentService 管理的线程。

其次,您不能将 DOM Document 放入 Intent extra 中。

But is this a proper way to go or is it better to use another approach?

就您而言,没有两项服务。将它们合并到一个服务中,您不必担心出现问题。

关于java - 如何传递 XML Document 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140086/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com