gpt4 book ai didi

android - 从服务获取数据到 Activity

转载 作者:行者123 更新时间:2023-11-30 04:47:08 43 4
gpt4 key购买 nike

在我的应用程序中,我有一个读取 rss 提要的服务。服务完成读取后,我需要更新我的应用程序并使用下载的信息填充 ListView 。使用广播接收器和 Intent 将不起作用,因为数据存储在自定义对象中。最好的方法是什么?

最佳答案

Using a broadcast receiver, and intents would not work, because the data is stored in a custom object.

然后不要将数据存储在“自定义对象”中。

What is the best way to do that?

第 1 步:使用数据库。

第 2 步:通过广播 Intent 或通过传入服务的 Messenger 或通过PendingIntentcreatePendingResult() 创建,或通过 ContentProvider facade 和内容观察器等传递到服务中。

第 3 步:让 Activity 从数据库中加载数据,也许只需在未完成的 Cursor 上调用 requery()

关于android - 从服务获取数据到 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4606141/

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