search

Home  >  Q&A  >  body text

android - activity之间传递图片怎么样比较好?

传递url还是bitmap?
为什么?
回答简洁一点,谢谢。

怪我咯怪我咯2772 days ago386

reply all(5)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:44:39

    What’s the scene like? Does this picture already have a corresponding bitmap object in the first activity?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:44:39

    No matter what the scenario is, try not to pass objects, especially bitmap objects that may be large and expensive. Pass a URL to load. It should be cached anyway

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 17:44:39

    Use DiskLruCache, MemoryLruCache secondary cache, just pass the URL, but the overhead of passing the object is too high

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 17:44:39

    Thank you for the invitation. What was said above is very clear. If there is a URL, the preferred URL is preferred. If not, caching can be considered. It is best not to pass Bitmap in the form of Intent. Large images may not be passed, and TransactionTooLargeException will appear

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:44:39

    If it is a picture obtained locally or from the Internet, of course it is best to pass the URI URL or something.
    If it is a drawn picture, I originally used a class to manage it and use static variables to access it, so that it can be used globally. There is no need to pass it around, just empty it after use.

    reply
    0
  • Cancelreply