Discover compress files on android, include the articles, news, trends, analysis and practical advice about compress files on android on alibabacloud.com
= Decodesampledbitmapfromresource (
Getresources (), params[0], 100);
Addbitmaptomemorycache (string.valueof (params[0]), bitmap);
return bitmap;
}
}
Master the above two methods, whether it is to load large images in the program, or to load a large number of pictures, do not worry about oom problem! But just a theoretical introduction does not know that we can not fully understand, in the following article I will demonstrate how to use the flexible application of the above techn
Android: How to obtain and compress local Images,
During the two days of Project creation, the image upload function encountered two problems: how to obtain the path of the selected image, and how to compress the image, after checking some information and reading what others wrote, I finally made a hard move and recorded it here.
First, to select images, we need
These two days in the project, do upload picture function piece, encounter two problems, one is how to get the path of the selected picture, one is how to compress the picture, after checking some information and read someone else to write after finally toss out, in this record.First of all, since we want to select pictures, we have to get all the pictures locally, and Android has encapsulated the intent fo
desired height to reduce the image to px* @param aimsize image compression target size, in kilobytes*/public static Bitmap Comp (Bitmap image, float aimwidth, float aimheight,int aimsize) {Bytearrayoutputstream BAOs = new Bytearrayoutputstream ();Image.compress (Bitmap.CompressFormat.JPEG, BAOs);if (Baos.tobytearray () length/1024) > 1024) {//Determine if the picture is greater than 1M, if it is, compress it to avoid creating the picture ()Baos.reset
With the development of mobile phone hardware, android camera functions become more and more powerful, and can find high-resolution images.In some scenarios, you need to take photos and upload them to the service. However, because the image size is too large, uploading will be very slow (in some network scenarios) and will consume a lot of traffic, to achieve high speed, we need to reduce the image size. There are two ways to reduce the image size: 1.
First of all, since we want to select pictures, we have to get all the pictures locally, and Android has encapsulated the intent for us.1 New null); // Select an item from the list and return all data 2 Intent.setdataandtype (3 MediaStore.Images.Media.EXTERNAL_CONTENT_URI,// get all pictures of the system 4 "image/*"); // type of picture, image/* for all types of pictures 5 Startactivityforresult (Intent, photo_ga
Many times in the project we need to use the input box Input,input focus will call the phone keypad, this time we if the current page maximum element width is the actual pixel, it is not a problem, but if the writing is hundred percent on the Android machine on the current page will be compressed upward, But mobile side we have to make adaptive, we can not write a fixed width high, then how to solve, first we could get the current mobile device width
public static Bitmap Revitionimagesize (String path) throws IOException {Bufferedinputstream in = new Bufferedinputstream ( New FileInputStream (path)); Bitmapfactory.options Options = new Bitmapfactory.options (); options.injustdecodebounds = true; Bitmapfactory.decodestream (in, null, options); In.close (); int i = 0; Bitmap Bitmap = Null;while (True) {if (options.outwidth >> i How to compress Android ima
outermost layout . Addonlayoutchangelistener (New Onlayoutchangelistener () {@Overridepublic void Onlayoutchange (View arg0, int arg1, int arg2, int arg3,int arg4, int arg5, int arg6, int arg7, int arg8) {TODO auto-generated Method Stubif (EditText. Hasfocus ()) {/*** There is no use of handler, so Sroderscrollview will not scroll to the bottom. Just scrolls the initialization height.* All scroll to the bottom if scrollview too long will cause edittext to roll out of the screen* New Handler ().
item2.xml passed into the View object, so you can use method, Setcontentview (R.layout.activity_main) in the main function is also the load XML, which displays the contents of the//xml in the current activity. Because the activity of the main function inherits the view, it is actually a container of the view, so the main function can use the Findviewbyid method directly, can only find the ID of the space in the Activity_main, so if you want to use in other classes Span style= "color: #ff000
Reading and Writing Android files and reading and writing Android files
Android uses IO streams to read and write files in the same way as JavaSE. In addition, Android uses the JavaSE I
-compressed"}, {". txt", "Text/plain"},{". wav", "Audio/x-wav"}, {". wma", "audio/x-ms-wma"},{". wmv", "audio/x-ms-wmv"},{". wps", "Application/vnd.ms-works"}, {". xml", "Text/plain"},{". Z", "Application/x-compress"},{". zip", "application/x-zip-compressed"}, {"", "*/*"}};The resulting producttpye is the suffix of the file. such as. jpgIf there is such a result is the bestWrite this article is only to let oneself in the development of more smooth, po
First of all, the premise of achieving all this is that your AVD Android simulator, before starting, has the size of the sdcard set well, such as. At the same time, your AVD Android simulator should be in the boot state. Otherwise, you cannot perform the following actions.Here's an example of an Android development environment installed in Windows using the Adt-b
[Android] copies external files to sdcard on AVD Android simulator, and browses sdcard files in AVD,
First, you must set the size of the sdcard before starting your AVD Android simulator, for example. At the same time, your AVD Android
Reading and Writing files in android and reading and writing files in androidRead and Write files in android
There is only one disk in android, and the forward slash/Represents the root directory.
The common SDK is/mnt/sdcard.
Tw
Android: Saving and reading files; android: Saving and reading filesContext. MODE_PRIVATE: The default operation mode indicates that the file is private data and can only be accessed by the application itself. In this mode, the written content will overwrite the content of the original file, if you want to append the newly written content to the original file. Yo
Android generates xml files and android generates xml files.
Generate an XML file backup text message in the following format:
Create an Sms class
package com.wuyudong.createxml.domain;public class Sms { private String body; private String date; private String type; private String address; public Sms(St
Android: How to locally load pdf files, android: how to load pdf files
Most apps open PDF files by using intent to enable the mobile phone to open PDF files to view the PDF files. If yo
Android clears useless resource files and android resource files from the project.1. Call the Android lint command to find useful resources and generate a list:
Command: lint-check "UnusedResources" [project_path]> result.txtAfter execution, a configuration file is generate
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.