the one in the album is found. If the picture is deleted from the album, the image in the specified path is left in the cell phone, wasting memory !!!
In short, I personally think the above method is a little pitfall.
Delete images
Private void DeleteImage (String imgPath) {ContentResolver resolver = context. getContentResolver (); Cursor cursor = MediaStore. images. media. query (resolver, MediaStore. ima
(cursor.getColumnIndex(ImageColumns.DATA)));photos.add(photoModel);}} while (cursor.moveToPrevious());return photos;}
(4) Take a photo and update the local photo in time
Public void photo () {// Intent openCameraIntent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); // startActivityForResult (openCameraIntent, TAKE_PICTURE); try {File dir = new File (Environment. getExternalStorageDirectory () + "/" + localTempImgDir); System. out. pri
Android multimedia-System camera
To take a photo with a system camera and return the photo, follow these steps:[1] Permission
[2] Start the camera with intent
Intent intent = new Intent (); intent. setAction (MediaStore. ACTION_IMAGE_CAPTURE); // implicitly start the System camera
[3] set the image storage location and name
File = new File (Environment. getExternalStorageDirectory (), System. currentTimeMillis () +. jpg); // create a new
obtain images. The first is camera shooting, and the second is to obtain images from a local album.
2. I created a folder on the SD card with two Uris. One is used to save the original image and the other is the saved cropped image. I have previously considered using the same Uri to save the image, but in practice I encountered a problem. If the image is not cropped after being taken, the next time I get the image from the SD card, it will be the big image saved by the photo, not only does the
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 to obtain all local images first. Android has encapsulated this intent for us.
1 Intent intent = new Intent (Intent. ACTION_PICK, null)
Android multimedia-learn to use the system camera in step 5
To take a photo with a system camera and return the photo, follow these steps:[1] Permission
[2] Start the camera with intent
Intent intent = new Intent (); intent. setAction (MediaStore. ACTION_IMAGE_CAPTURE); // implicitly start the System camera
[3] set the image storage location and name
File = new File (Environment. getExternalStorageDirectory (), System. currentTimeMillis (
(); initEvent ();}/*** uses ContentProvider to scan pictures on your mobile phone. This method scans images in the Child thread, the folder with the most jpg files */private vo Id getImages () {if (! Environment. getExternalStorageState (). equals (Environment. MEDIA_MOUNTED) {Toast. makeText (this, "No external storage", Toast. LENGTH_SHORT ). show (); return;} // display the progress bar mProgressDialog = ProgressDialog. show (this, null, "loading... "); new Thread (new Runnable () {@ Overrid
(cursor.getLong(cursor.getColumnIndex(ImageColumns.SIZE)) > 1024 * 10) {PhotoModel photoModel = new PhotoModel();photoModel.setOriginalPath(cursor.getString(cursor.getColumnIndex(ImageColumns.DATA)));photos.add(photoModel);}} while (cursor.moveToPrevious());return photos;}
(4) Take a photo and update the local album in time
Public void photo () {// Intent openCameraIntent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); // startActivit
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.