Recently, the boss requested to upload and download images from the android client by calling the WebService interface of the server to upload images from Android to the server, and then download images from the server to the android
Android loads large images to memory,
This article demonstrates how to load images to memory in android
First, design the interface:
The Code is as follows:
Upload test images to mnt/sdcard
Add the logic code:
public class MainActivity extends Activity { private ImageVi
games in the algorithm processing is not a problem, the main impact of the performance bottleneck is Android's own memory management mechanism, the mobile phone manufacturers are stingy with RAM, for the smoothness of the software, the impact of RAM on performance is very sensitive, In addition to optimizing heap memory allocations for Dalvik virtual machines mentioned in the last Android development netwo
is then a local stretch, so if the rounded point 9 picture is placed in the low pixel density resource folder, when using high pixel density device display, The image is zoomed in to a local stretch, which causes the picture's rounded corners and edges to be stretched during magnification, blurring the display.
Solution:
1, try to place the point 9 picture in the high pixel density resource folder, so that even if the image is displayed on low pixel density
Because of the limited mobile phone traffic, when using Android phones, we should consider for users as much as possible to consume less user traffic, in applications, the display of network images is undoubtedly the most traffic-consuming. Therefore, we can compress images or cache
"loading" is displayed in the imageview;
The image is downloaded in the background and displayed in the imageview after the download is complete;
If the image fails to be downloaded, imageview displays a bitmap indicating that the image fails to be downloaded;
Next let's take a look at the implementationCode:
First, you need a method to download the remote image. Here we do not need to download the image to your mobile phone, and direct
A thumbnail ThumbnailUtils class has been added to the system since Android 2.2, which is located in the framework's android. media. the location of ThumbnailUtils can help us obtain thumbnails of video or image files in the system from mediaprovider. This class provides three static methods that can be called directly. 1. static Bitmap createVideoThumbnail (String filePath, int kind) // obtain the thumbnai
We all know that the system will call the MediaScanner Service to perform background scanning and index new songs, images, videos, and other information when the SD card is inserted in Android 1.5, if you need to quickly extract images and video thumbnails, you can directly access android. provider. mediaStore.
I have just tossed a small program to display pictures, but it is quite comfortable to look at on a resolution phone. Some other resolution phones are too small or too big, after searching for information on the Internet, I wrote a program to test it.
Android also considers this situation. The res directory contains three subdirectories (drawable-hdpi, drawable-mdpi, and drawable-ldpi.
Hdpi is used to store
1. Convert the image into a thumbnail and load it again:
The Code is as follows:1 BitmapFactory. Options options = new BitmapFactory. Options ();2 options. inSampleSize = 2;3 Bitmap img = BitmapFactory. decodeFile ("/sdcard/1.png", options );
This code is used to read the thumbnail of 1.png. The length and width are only 1/2 of the original image. The image size is reduced, and the memory occupied is naturally reduced. The disadvantage of this is that the image quality is deteriorated. The large
Content of this article
Environment
Demonstrate
Download DemoEnvironment
Windows R2 64-bit
Eclipse ADT v22.6.2,android 4.4.3
SAMSUNG gt-i9008l,android OS 2.2.2
DemonstrateThumbnails can reduce the memory consumption of your phone. The resources on the network generally to the
A thumbnail thumbnailutils class has been added to the system since Android 2.2, which is located in the framework's Android. media. the location of thumbnailutils can help us obtain thumbnails of video or image files in the system from mediaprovider. This class provides three static methods that can be called directly.
1.
Static bitmap createvideothumbnail (string filepath, int kind) // obtain the thumbnai
Android takes pictures and saves them (compressing and splitting images ),
A small function module extracted from the project. If you need it, you can use it for reference.
:
Function: Save the photo to SDcard.
Specific requirements:
1. Save the image name in the format of: image name _ mobile phone number _random 4 bits .jpg
2. Break down, compress, and di
The implementation of this demo is to call the camera installed on the phone to achieve the function of taking pictures, the photos taken in imageview form display.Objective: To learn how to use mobile phone to install camera cameras, to understand the large picture processing, here mainly used in Bitmapfactory and bitmapfactory.options two classes.Loading and displaying a pair of
games in the algorithm processing is not a problem, the main impact of the performance bottleneck is Android's own memory management mechanism, the mobile phone manufacturers are stingy with RAM, for the smoothness of the software, the impact of RAM on performance is very sensitive, In addition to optimizing heap memory allocations for Dalvik virtual machines mentioned in the last Android development netwo
Android-1-phone dial
Project package src -- java source code gen folder -- resource file, automatically generated after modification --- R. the drawable class in java corresponds to the drawable directory in the directory, layout corresponds to the layout directory, and String corresponds to the assets folder in the String directory to store large files, such as videos, audios, fonts, etc. (1 GB will not
I. Two types of image classificationBitmaps: Also known as bitmap images or drawing images, are made up of a series of individual dots of pixels. These points can be arranged differently and dyed to form a pattern. When you enlarge a bitmap, it makes the lines and shapes appear uneven.Vector graphs: Also known as object-oriented images or drawing
This article illustrates how Android uses Contentresolver to search for a phone address book. Share to everyone for your reference, specific as follows:
Use Contentresolver in this program to access the Contacts keyword in your address book and deposit all the contacts you find in CursorAdapter. Enter the name of the search person A, will all start with a name will be displayed, input *, then all the names
In Android development, the image cropping function is sometimes used. At this time, we often call the system's own cropping (defining a file that contains COM. android. camera. action. crop action intent), although this is very simple, but the system cropping has many problems in the adaptability of mobile phones, which is difficult to control. Therefore, we decided to write our own code to get this croppi
Android development package the project into an apk, Android to the mobile phone, or submit it to the app Store, androidapk#1. It is easy to export an app using Eclipse. Let's take a look at my steps. Images and truth
Select a project
Create a new one with a random location. The following is the password.
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.