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. images. thumbnails and android. provider. mediaStore. video. thumbnails databases can be used to query Thumbnails.
How to determine files? You can use Cursor to traverse the database and compare the value of the INTERNAL_CONTENT_URI field. This is a Uri that can be converted to a String. Here, the complete path of the multimedia file on the Android mobile phone SD card is saved,
For specific thumbnails, you can use getThumbnail (ContentResolver cr, long origId, int kind, BitmapFactory. options options) or getThumbnail (ContentResolver cr, long origId, long groupId, int kind, BitmapFactory. options options) method, the two methods return the Bitmap type, while the thumbnail resolution can be extracted from the HEIGHT and WIDTH fields. on Android, there are two types of thumbnails, by reading the KIND field, the MICRO_KIND and MINI_KIND modes are both micro-and mini-scaling modes. The former has lower resolution. In this way, we can directly call the system thumbnails when obtaining an image preview of the file system, instead of re-computing it by ourselves.
Finally, Android123 prompts you to save the thumbnails in the dcim directory of the SD card. thumbnails is an image, while. video_thumbnails is a video. These two folders are hidden attributes and can be seen in common file managers.
A thumbnail ThumbnailUtils class is added from Android2.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 thumbnail of the video file. The first parameter is the location of the video file, such as/sdcard/android123.3gp, the second parameter can be MINI_KIND or MICRO_KIND, which is ultimately related to resolution.
2. static Bitmap extractThumbnail (Bitmap source, int width, int height, int options) // scale Bitmap directly. The last parameter is defined as OPTIONS_RECYCLE_INPUT to recycle resources.
3. static Bitmap extractThumbnail (Bitmap source, int width, int height) // This is the same as the preceding method, and there is no options Option
Finally, the Android Development Network reminds everyone that the ThumbnailUtils class is supported by the API Level from 8 or higher.
Author "ljbal"