manner, potentially causing an application to briefly exceed its memory limits and crash.
Therefore, we generally use the LruCache class. This class can be understood as follows: it is a memory cache object, and your images are cached in this class. (IN Java, everything is an object .)Only in 12, but fortunately Android officially added it to the v4 package, so this class can be used in Versions later tha
Android developer:
It is easy to load an image on the UI. However, if you need to load multiple large images, it will become more complicated ,. In many cases (such as the components of the listview gridview or viewpager with an image), the total number of images on the screen increases suddenly with the scrolling on the screen and is basically infinite. To keep the memory usage in a stable range, these components will recycle the sub-view after it
order to choose a suitable size for LRUCache, there are a number of reasons to consider, such as:Are other activity (activities) and/or programs very memory-intensive?How many pictures are displayed on the screen at a time? How many pictures will be displayed on the screen?What is the screen size and density of the device? An ultra-high-definition screen (XHDPI) device, such as the Galaxy Nexus, caches the same number of images for more cache space t
In the previous article in the cache object we mentioned that there are three places where the object data is cached, and here's a detailed:1 (/data/data/com.xxx.xxx/cache) apply the private cache directory, belong to the internal cache, other applications can not access, generally store smaller data;2 (/mnt/sdcard/
.
Handling Configuration Change Events
Runtime configuration changes-such as screen orientation changes-cause Android to destroy the running activity and then useThe new configuration restarts the activity (for more information, refer here to handling Runtime Changes).You need to be aware that you can improve the user experience by avoiding the process of reprocessing all the pictures when configuration
The previous article said that Android LRU cache algorithm implementation of the learning Note (a) we introduced the most common implementation of the LRU cache data Structure Linkedhashmap, this section we will focus on the characteristics of LINKEDHASHMAP data structure, To implement the cache structure and learn the
I. Description of the problem
Android applications often involve loading a large number of images from the network, in order to increase the speed and efficiency of loading, reduce network traffic will adopt two-level caching and asynchronous loading mechanism, the so-called two-level cache is obtained from memory, and then from the file to obtain, the last access to the network. The memory
);bitmapdrawable bd = new bitmapdrawable (this.getresources (), BM);Mbtn.setbackgrounddrawable (BD);To replace Mbtn.setbackgroundresource (R.drawable.splash).When destroying, use:bitmapdrawable BD = (bitmapdrawable) mbtn.getbackground ();Mbtn.setbackgroundresource (0);//Don't forget to set the background to NULL to avoid used a recycled bitmap error when OnDraw refresh the backgroundBd.setcallback (NULL);Bd.getbitmap (). Recycle ();This adjustment, to avoid the
Android Cache:The use of cache, can further greatly alleviate the pressure of data interaction, but also to provide a certain offline browsing. Let me briefly list the applicable environment for cache management:1. Application of network Services2. Data updates do not need to be updated in real time, and even a 3-5-minute delay can be implemented with a caching m
Android Cache:The use of cache, can further greatly alleviate the pressure of data interaction, but also to provide a certain offline browsing. Let me briefly list the applicable environment for cache management:1. Application of network Services2. Data updates do not need to be updated in real time, and even a 3-5-minute delay can be implemented with a caching m
[Android Studio] explores the cache mechanism of webView in depth, androidwebview
Webview has been around recently. Android Developers may know that webView has its own caching mechanism. company needs to write its own caching mechanism instead of webView, wow, it's challenging. I wrote this blog to record my learning process. Not easy to write, Do not spray.Fir
(which can be supported to sdk4 through a Compatibility Pack) is ideal for image caching, which stores images by Linkedhashmap keeping images strong, and frees up early caches when the cache space exceeds the set limit.Note: In the past, common memory cache implementations were passed SoftReference or weakreference, but this is not recommended. The Android2.3 (API Level 9) garbage collector began to collec
Android data cache
Caching can further relieve the Data Interaction pressure and provide offline browsing. The following briefly describes the application environment of Cache Management:
1. applications that provide Network Services
2. Data Update does not need to be updated in real time. A cache mechanism can be used
to be necessary to put them into a database or file. After a comprehensive consideration, it seems that the memory cache is a good choice.
So this cache needs to provide the following features, first, it is a cache, secondly, its structure needs to be very simple, because many places need to use, again, it is thread-safe.
Later our implementation was simple, u
Detailed explanation of memory cache of Android image download framework UniversialImageLoader (3)
The previous two articles focus on disk caching. This article focuses on memory caching. I also want to explain the memory cache in two articles. In this article, we mainly focus on three categories,
MemoryCache, BaseMemoryCache, and LimitedMemoryCache.
First, let's
ObjectiveThis blog to achieve is an offline download and offline reading function, which is a lot of reading app is a common feature, the typical application is NetEase news. What is offline download? In fact, this concept is relatively vague, is offline after downloading it, or after downloading offline, but a little bit of brain people know how to download after the network? So offline download this feature is " in the case of a network, download resources to local ", offline reading is " in t
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.