【问题标题】:android intent image how to send it in best wayandroid意图图像如何以最佳方式发送
【发布时间】:2012-12-17 04:32:22
【问题描述】:

此时我有一个带有列表视图的活动 (lview),它使用从 url 和 simple activity (sact) 下载到临时文件的图像和 imageview

点击时,lview 中的textview 的值被选中并按意图发送到 sact,它与对象相关联。拾取对象后,对其进行解析并从中提取链接。然后这个链接用来下载图片。

 Intent in = new Intent(getApplicationContext(),
 SingleMenuItemActivity.class);
 in.putExtra("name", name);
 Log.d("Starting activity ", "Yeah ");
 startActivity(in);

事实上,这两个活动都使用相同的链接并引用网络中的相同图像。显然它是低效的。

如何从 lview 的图像视图中拍摄图片(或唯一 ID),然后将其发送到 sact?

【问题讨论】:

    标签: android image android-intent temporary-files


    【解决方案1】:

    您实质上要问的是如何使用意图在活动之间传递图像。这是可能的,但可能效率不高。据我所知,您只能将 ParcelableSeralizeable 对象添加到意图中。

    您真正应该考虑的是拥有一个图像下载服务,该服务将下载图像,并且 a) 将它们缓存在磁盘上,您可以从多个位置读取它们,b) 将它们缓存在内存中可访问的位置其他活动(即静态变量)或 c)两者。

    请参阅this SO question for more information on image cachingthis one for caching in general

    您也可以阅读what Android says about caching bitmaps in the documentation.


    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      • 2015-09-17
      • 1970-01-01
      • 1970-01-01
      • 2014-10-19
      相关资源
      最近更新 更多