Android 毕加索正在一个appwidget中使用缓存图像的数据

Android 毕加索正在一个appwidget中使用缓存图像的数据,android,caching,picasso,okhttp3,Android,Caching,Picasso,Okhttp3,我们有一个appwidget,它包含多个需要每隔一段时间用一个图像更新的ImageView。图像存储在web上,url存储在我们旋转的ArrayList中。我们正在使用毕加索的OkHttp3下载器,它有一个缓存。根据设置应用程序中的安卓内置数据使用选项,即使所有图像至少显示一次,我们的应用程序仍在使用数据。当打开飞行模式时,小部件将继续工作并显示所有图像,因此必须缓存这些图像。为什么毕加索在缓存图像的情况下仍在使用数据?(我们已经排除了应用程序/小部件使用数据的所有其他可能来源) 使用的图书馆:

我们有一个appwidget,它包含多个需要每隔一段时间用一个图像更新的ImageView。图像存储在web上,url存储在我们旋转的ArrayList中。我们正在使用毕加索的OkHttp3下载器,它有一个缓存。根据设置应用程序中的安卓内置数据使用选项,即使所有图像至少显示一次,我们的应用程序仍在使用数据。当打开飞行模式时,小部件将继续工作并显示所有图像,因此必须缓存这些图像。为什么毕加索在缓存图像的情况下仍在使用数据?(我们已经排除了应用程序/小部件使用数据的所有其他可能来源)

使用的图书馆:

  • com.squareup.okhttp3:okhttp:3.2.0
  • 毕加索:毕加索:2.5.2
  • 毕加索:毕加索2-okhttp3-downloader:1.1.0
Picasso在Application Object onCreate()中初始化:

从服务加载映像:

public static void updateImage(Context context, RemoteViews remoteViews, int resourceId, String url) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
    Picasso.with(context).load(url).into(remoteViews, resourceId, appWidgetIds);
}

还有,有人知道指标和日志对RemoteView不起作用是否正常吗?

回答我自己的问题,以防有人遇到类似问题


通过设计,HTTP请求被发送到服务器,服务器以304状态响应,即使缓存期限仍然有效,以便能够在服务器上测量图像显示的频率。我们在Android中看到的数据使用不是图像,而是大量的标题。

您是否尝试使用毕加索的
setIndicatorEnabled
来验证图像是否未从缓存加载?是的,但appwidget中没有显示任何指示。它们确实在应用程序本身中起作用。它们应该在AppWidget的RemoteView中工作吗?我看不出有任何理由不应该。。尽管如此,我自己还没有测试过。如果不是这样的话,也许值得一提
public static void updateImage(Context context, RemoteViews remoteViews, int resourceId, String url) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
    Picasso.with(context).load(url).into(remoteViews, resourceId, appWidgetIds);
}