安卓app如何获取小米安卓 获取路由器ip中视频的缩略图

APP看存储器的图片或视频怎么没有缩略图?_小米路由吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
APP看存储器的图片或视频怎么没有缩略图?收藏
而且电脑版的app功能太简单了,只有个什么链接下载功能,都不能访问存储器,还没手机app好用。求大神告知原因!
这个东西就这样有问题请加小米路由民间设置讨论Q群:
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或5392人阅读
android 相关知识(185)
要得到图片的缩略图,可以有两种方法:
一种是利用BitmapFactory中的decodeFile对图片进行压缩。
一种是直接取缩略图
直接访问 android.provider.MediaStore.Images.Thumbnails 和android.provider.MediaStore.Video.Thumbnails这两个数据库,可以获得设备中图片和视频的缩略图
// 取缩略图的方法
cr = getContentResolver();
String[] projection = { Thumbnails._ID, Thumbnails.IMAGE_ID, Thumbnails.DATA };
Cursor cursor = cr.query(Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, null);
getColumnData(cursor);
private void getColumnData(Cursor cur) {
&&& if (cur.moveToFirst()) {
&&&&&&& int _
&&&&&&& int image_
&&&&&&& String image_
&&&&&&& int _idColumn = cur.getColumnIndex(Thumbnails._ID);
&&&&&&& int image_idColumn = cur.getColumnIndex(Thumbnails.IMAGE_ID);
&&&&&&& int dataColumn = cur.getColumnIndex(Thumbnails.DATA);
&&&&&&& do {
&&&&&&&&&&& // Get the field values
&&&&&&&&&&& _id = cur.getInt(_idColumn);
&&&&&&&&&&& image_id = cur.getInt(image_idColumn);
&&&&&&&&&&& image_path = cur.getString(dataColumn);
&&&&&&&&&&& // Do something with the values.
&&&&&&&&&&& Log.i(TAG, _id + & image_id:& + image_id + & path:&
&&&&&&&&&&&&&&&&&&&&&&& + image_path + &---&);
&&&&&&&&&&& HashMap&String, String& hash = new HashMap&String, String&();
&&&&&&&&&&& hash.put(&image_id&, image_id + &&);
&&&&&&&&&&& hash.put(&path&, image_path);
&&&&&&&&&&& list.add(hash);
&&&&&&& } while (cur.moveToNext());
// 取实际图片的方法
String columns[] = new String[] { Media.DATA, Media._ID, Media.TITLE, Media.DISPLAY_NAME, Media.SIZE }; &
// 得到一个游标 &
cursor = this.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, columns, null, null, null); &
// 获取指定列的索引 &
photoIndex = cursor.getColumnIndexOrThrow(Media.DATA); &
photoNameIndex = cursor.getColumnIndexOrThrow(Media.DISPLAY_NAME); &
photoIDIndex = cursor.getColumnIndexOrThrow(Media._ID); &
photoTitleIndex = cursor.getColumnIndexOrThrow(Media.TITLE); &
photoSizeIndex = cursor.getColumnIndexOrThrow(Media.SIZE); &
// 获取图片总数 &
totalNum = cursor.getCount();&
// 因为缩略图数据库和实际图数据库的id是相同的,所以可以根据取出的缩略图的id去找开真正的图片
OnItemClickListener listener = new OnItemClickListener() {& &
&&& @Override &
&&& public void onItemClick(AdapterView&?& parent, View view, int position, long id) { &
&&&&&&& // TODO Auto-generated method stub &
&&&&&&& String image_id = list.get(position).get(&image_id&); &
&&&&&&& Log.i(TAG, &---(^o^)----& + image_id); &
&&&&&& String[] projection = { Media._ID, Media.DATA }; &
&&&&&& Cursor cursor = cr.query(Media.EXTERNAL_CONTENT_URI, projection, &
&&&&&&&&&&&&&&&&&&&&&&&&&&&& Media._ID + &=& + image_id, null, null); &
&&&&&& if (cursor != null) { &
&&&&&&&&&& cursor.moveToFirst(); &
&&&&&&&&&& String path = cursor.getString(cursor.getColumnIndex(Media.DATA)); &
&&&&&&&&&& Intent intent = new Intent(ThumbnailActivity.this, ImageViewer.class); &
&&&&&&&&&& intent.putExtra(&path&, path); &
&&&&&&&&&& startActivity(intent); &
&&&&&& } else { &
&&&&&&&&&& Toast.makeText(ThumbnailActivity.this, &Image doesn't exist!&, &
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Toast.LENGTH_SHORT).show(); &
&&&&&&&&& }
有关具体的缩略图可以通过getThumbnail(ContentResolver cr, long origId, int kind, BitmapFactory.Options options) 或getThumbnail(ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options) 方法获取,这两种方法返回Bitmap类型,而缩略图的分辨率可以从HEIGHT和WIDTH两个字段提取,在Android上缩略图分为两种,通过读取
KIND字段来获得,分别为MICRO_KIND和MINI_KIND 分别为微型和迷你两种缩略模式,前者的分辨率更低。这样我们平时获取文件系统的某个图片预览时,可以直接调用系统缩略图,而不用自己重新计算。
缩略图保存在SD卡的DCIM目录,里面的.thumbnails是图片的,而.video_thumbnails是视频的,这两个文件夹为隐藏属性
--------------------------------------------------------------------------------------
从Android2.2开始系统新增了一个缩略图ThumbnailUtils类,位于framework的 android.media.ThumbnailUtils位置,可以帮助我们从mediaprovider中获取系统中的视频或图片文件的缩略图,该类提供了三种静态方法可以直接调用获取。
1. static Bitmap createVideoThumbnail(String filePath, int kind)
//获取视频文件的缩略图,第一个参数为视频文件的位置,比如/sdcard/android123.3gp,而第二个参数可以为MINI_KIND或 MICRO_KIND最终和分辨率有关
2. static Bitmap extractThumbnail(Bitmap source, int width, int height, int options)
//直接对Bitmap进行缩略操作,最后一个参数定义为OPTIONS_RECYCLE_INPUT,来回收资源
3. static Bitmap extractThumbnail(Bitmap source, int width, int height)
// 这个和上面的方法一样,无options选项&
--------------------------------------------------------------------------------------
获取音频文件:
&Cursor cursor = getContentResolver().query( &
&&&&&&&&&&&&&&&& MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, &
&&&&&&&&&&&&&&&& MediaStore.Audio.Media.DEFAULT_SORT_ORDER); &
&cursor.moveToFirst(); &
int counter = cursor.getCount(); &
String title = cursor.getString(cursor &
&&&&&&&&&&&&&&&& .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE)); &
Log.w(&tag&, &before looping,title=& + title); &
for (int j = 0; j & j++) { &
&&& Log.w(&tag&, &title=& + cursor.getString(cursor &
&&&&&&&&&&&&&&&&&&&& .getColumnIndex(MediaStore.Audio.Media.TITLE))); &
&&& cursor.moveToNext(); &
cursor.close();
---------------------------------------------------------------------------------------
增加,代码如下所以:
ContentValues values = new ContentValues(); &
values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER,0); &
resolver.insert(_uri, values); &
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER,0);
resolver.insert(_uri, values);
这个insert传递的参数只有两个,一个是Uri(同查询那个Uri),另一个是ContentValues。这个ContentValuses对应于数据库的一行数据,只要用put方法把每个列的设置好之后,直接利用insert方
法去插入就好了。
更新,代码如下:
ContentResolver resolver = ctx.getContentResolver(); &
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; &
ContentValues values = new ContentValues(); &
values.put(MediaStore.Audio.Media.DATE_MODIFIED, sid); &
resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,values, where, selectionArgs); &
ContentResolver resolver = ctx.getContentResolver();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Media.DATE_MODIFIED, sid);
resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,values, where, selectionArgs);
上面update方法和查询还有增加里的参数都很类似,这里就不再重复叙述了,大家也可直接参考google的文档,那里也写的很清楚。
删除,代码如下:
ContentResolver resolver = ctx.getContentResolver(); &
resolver.delete(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,where, selectionArgs); &
ContentResolver resolver = ctx.getContentResolver();
resolver.delete(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,where, selectionArgs);
//--------------------------------------------------------------------------------
在实际开发中遇到一个问题,只能读出一个文件的缩略图,在/mnt/sdcard/DCIM/.Thumbnails下,也只有一个缩略图文件
另外还有一个文件 image_last_thumb
因时间太紧张没有清楚查到原因,网上有说是和sd卡的类型有关,因为不明白原因,无奈之下只有使用取原图压缩的办法。
http://forum./showthread.php?t=558168&page=2
// -------------------------------------------------------------------------------
/android/mydroid/donut/packages/apps/Camera/src/com/android/camera/ImageManager.java
&* Copyright (C) 2007 The Android Open Source Project
&* Licensed under the Apache License, Version 2.0 (the &License&);
&* you may not use this file except in compliance with the License.
&* You may obtain a copy of the License at
&*&&&&& http://www.apache.org/licenses/LICENSE-2.0
&* Unless required by applicable law or agreed to in writing, software
&* distributed under the License is distributed on an &AS IS& BASIS,
&* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
&* See the License for the specific language governing permissions and
&* limitations under the License.
package com.android.
import com.android.camera.gallery.BaseC
import com.android.camera.gallery.BaseImageL
import com.android.camera.gallery.C
import com.android.camera.gallery.DrmImageL
import com.android.camera.gallery.II
import com.android.camera.gallery.IImageL
import com.android.camera.gallery.I
import com.android.camera.gallery.ImageL
import com.android.camera.gallery.ImageListU
import com.android.camera.gallery.SingleImageL
import com.android.camera.gallery.VideoL
import com.android.camera.gallery.VideoO
import android.content.ContentR
import android.content.ContentU
import android.content.ContentV
import android.database.C
import android.graphics.B
import android.location.L
import android.net.U
import android.os.E
import android.os.P
import android.provider.DrmS
import android.provider.MediaS
import android.provider.MediaStore.I
import android.provider.MediaStore.Images.ImageC
import android.util.L
import java.io.F
import java.io.IOE
import java.util.ArrayL
import java.util.HashM
import java.util.I
import java.util.concurrent.ExecutionE
&* ImageManager is used to retrieve and store images
&* in the media content provider.
public class ImageManager {
&&& private static final String TAG = &ImageManager&;
&&& private static final Uri STORAGE_URI = Images.Media.EXTERNAL_CONTENT_URI;
&&& private static final Uri THUMB_URI
&&&&&&&&&&& = Images.Thumbnails.EXTERNAL_CONTENT_URI;
&&& private static final Uri VIDEO_STORAGE_URI =
&&&&&&&&&&& Uri.parse(&content://media/external/video/media&);
&&&& * Enumerate type for the location of the images in gallery.
&&& public static enum DataLocation { NONE, INTERNAL, EXTERNAL, ALL }
&&& public static final Bitmap DEFAULT_THUMBNAIL =
&&&&&&&&&&& Bitmap.createBitmap(32, 32, Bitmap.Config.RGB_565);
&&& public static final Bitmap NO_IMAGE_BITMAP =
&&&&&&&&&&& Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
&&& public static final int SORT_ASCENDING = 1;
&&& public static final int SORT_DESCENDING = 2;
&&& public static final int INCLUDE_IMAGES = (1 && 0);
&&& public static final int INCLUDE_DRM_IMAGES = (1 && 1);
&&& public static final int INCLUDE_VIDEOS = (1 && 2);
&&& public static final String CAMERA_IMAGE_BUCKET_NAME =
&&&&&&&&&&& Environment.getExternalStorageDirectory().toString()
&&&&&&&&&&& + &/DCIM/Camera&;
&&& public static final String CAMERA_IMAGE_BUCKET_ID =
&&&&&&&&&&& getBucketId(CAMERA_IMAGE_BUCKET_NAME);
&&&& * Matches code puteBucketValues. Should be a common
&&&& * function.
&&& public static String getBucketId(String path) {
&&&&&&& return String.valueOf(path.toLowerCase().hashCode());
&&&& * OSX requires plugged-in USB storage to have path /DCIM/NNNAAAAA to be
&&&& * imported. This is a temporary fix for bug#1655552.
&&& public static void ensureOSXCompatibleFolder() {
&&&&&&& File nnnAAAAA = new File(
&&&&&&&&&&& Environment.getExternalStorageDirectory().toString()
&&&&&&&&&&& + &/DCIM/100ANDRO&);
&&&&&&& if ((!nnnAAAAA.exists()) && (!nnnAAAAA.mkdir())) {
&&&&&&&&&&& Log.e(TAG, &create NNNAAAAA file: & + nnnAAAAA.getPath()
&&&&&&&&&&&&&&&&&&& + & failed&);
&&& public static int roundOrientation(int orientationInput) {
&&&&&&& int orientation = orientationI
&&&&&&& if (orientation == -1) {
&&&&&&&&&&& orientation = 0;
&&&&&&& orientation = orientation % 360;
&&&&&&& int retV
&&&&&&& if (orientation & (0 * 90) + 45) {
&&&&&&&&&&& retVal = 0;
&&&&&&& } else if (orientation & (1 * 90) + 45) {
&&&&&&&&&&& retVal = 90;
&&&&&&& } else if (orientation & (2 * 90) + 45) {
&&&&&&&&&&& retVal = 180;
&&&&&&& } else if (orientation & (3 * 90) + 45) {
&&&&&&&&&&& retVal = 270;
&&&&&&& } else {
&&&&&&&&&&& retVal = 0;
&&&&&&& return retV
&&&& * @return true if the mimetype is an image mimetype.
&&& public static boolean isImageMimeType(String mimeType) {
&&&&&&& return mimeType.startsWith(&image/&);
&&&& * @return true if the mimetype is a video mimetype.
&&& public static boolean isVideoMimeType(String mimeType) {
&&&&&&& return mimeType.startsWith(&video/&);
&&&& * @return true if the image is an image.
&&& public static boolean isImage(IImage image) {
&&&&&&& return isImageMimeType(image.getMimeType());
&&&& * @return true if the image is a video.
&&& public static boolean isVideo(IImage image) {
&&&&&&& // This is the right implementation, but we use instanceof for speed.
&&&&&&& //return isVideoMimeType(image.getMimeType());
&&&&&&& return (image instanceof VideoObject);
&&& public static void setImageSize(ContentResolver cr, Uri uri, long size) {
&&&&&&& ContentValues values = new ContentValues();
&&&&&&& values.put(Images.Media.SIZE, size);
&&&&&&& cr.update(uri, values, null, null);
&&& public static Uri addImage(ContentResolver cr, String title,
&&&&&&&&&&& long dateTaken, Location location,
&&&&&&&&&&& int orientation, String directory, String filename) {
&&&&&&& ContentValues values = new ContentValues(7);
&&&&&&& values.put(Images.Media.TITLE, title);
&&&&&&& // That filename is what will be handed to Gmail when a user shares a
&&&&&&& // photo. Gmail gets the name of the picture attachment from the
&&&&&&& // &DISPLAY_NAME& field.
&&&&&&& values.put(Images.Media.DISPLAY_NAME, filename);
&&&&&&& values.put(Images.Media.DATE_TAKEN, dateTaken);
&&&&&&& values.put(Images.Media.MIME_TYPE, &image/jpeg&);
&&&&&&& values.put(Images.Media.ORIENTATION, orientation);
&&&&&&& if (location != null) {
&&&&&&&&&&& values.put(Images.Media.LATITUDE, location.getLatitude());
&&&&&&&&&&& values.put(Images.Media.LONGITUDE, location.getLongitude());
&&&&&&& if (directory != null && filename != null) {
&&&&&&&&&&& String value = directory + &/& +
&&&&&&&&&&& values.put(Images.Media.DATA, value);
&&&&&&& return cr.insert(STORAGE_URI, values);
&&& private static class AddImageCancelable extends BaseCancelable&Void& {
&&&&&&& private final Uri mU
&&&&&&& private final ContentResolver mCr;
&&&&&&& private final int mO
&&&&&&& private final Bitmap mS
&&&&&&& private final byte [] mJpegD
&&&&&&& public AddImageCancelable(Uri uri, ContentResolver cr,
&&&&&&&&&&&&&&& int orientation, Bitmap source, byte[] jpegData) {
&&&&&&&&&&& if (source == null && jpegData == null || uri == null) {
&&&&&&&&&&&&&&& throw new IllegalArgumentException(&source cannot be null&);
&&&&&&&&&&& }
&&&&&&&&&&& mUri =
&&&&&&&&&&& mCr =
&&&&&&&&&&& mOrientation =
&&&&&&&&&&& mSource =
&&&&&&&&&&& mJpegData = jpegD
&&&&&&& @Override
&&&&&&& protected Void execute() throws InterruptedException,
&&&&&&&&&&&&&&& ExecutionException {
&&&&&&&&&&& boolean complete =
&&&&&&&&&&& try {
&&&&&&&&&&&&&&& long id = ContentUris.parseId(mUri);
&&&&&&&&&&&&&&& BaseImageList il = new ImageList(
&&&&&&&&&&&&&&&&&&&&&&& STORAGE_URI, THUMB_URI, SORT_ASCENDING, null);
&&&&&&&&&&&&&&& il.open(mCr);
&&&&&&&&&&&&&&& // TODO: Redesign the process of adding new images. We should
&&&&&&&&&&&&&&& //&&&& create an &code&IImage&/code& in &ImageManager.addImage&
&&&&&&&&&&&&&&& //&&&& and pass the image object to here.
&&&&&&&&&&&&&&& Image image = new Image(il, mCr, id, 0, il.contentUri(id), null,
&&&&&&&&&&&&&&&&&&&&&&& 0, null, 0, null, null, 0);
&&&&&&&&&&&&&&& String[] projection = new String[] {
&&&&&&&&&&&&&&&&&&&&&&& ImageColumns._ID,
&&&&&&&&&&&&&&&&&&&&&&& ImageColumns.MINI_THUMB_MAGIC, ImageColumns.DATA};
&&&&&&&&&&&&&&& Cursor c = mCr.query(mUri, projection, null, null, null);
&&&&&&&&&&&&&&& S
&&&&&&&&&&&&&&& try {
&&&&&&&&&&&&&&&&&&& c.moveToPosition(0);
&&&&&&&&&&&&&&&&&&& filepath = c.getString(2);
&&&&&&&&&&&&&&& } finally {
&&&&&&&&&&&&&&&&&&& c.close();
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& runSubTask(image.saveImageContents(
&&&&&&&&&&&&&&&&&&&&&&& mSource, mJpegData, mOrientation, true, filepath));
&&&&&&&&&&&&&&& ContentValues values = new ContentValues();
&&&&&&&&&&&&&&& values.put(ImageColumns.MINI_THUMB_MAGIC, 0);
&&&&&&&&&&&&&&& mCr.update(mUri, values, null, null);
&&&&&&&&&&&&&&& complete =
&&&&&&&&&&&&&&&
&&&&&&&&&&& } finally {
&&&&&&&&&&&&&&& if (!complete) {
&&&&&&&&&&&&&&&&&&& try {
&&&&&&&&&&&&&&&&&&&&&&& mCr.delete(mUri, null, null);
&&&&&&&&&&&&&&&&&&& } catch (Throwable t) {
&&&&&&&&&&&&&&&&&&&&&&& // ignore it while clean up.
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&& public static Cancelable&Void& storeImage(
&&&&&&&&&&& Uri uri, ContentResolver cr, int orientation,
&&&&&&&&&&& Bitmap source, byte [] jpegData) {
&&&&&&& return new AddImageCancelable(
&&&&&&&&&&&&&&& uri, cr, orientation, source, jpegData);
&&& public static IImageList makeImageList(Uri uri, ContentResolver cr,
&&&&&&&&&&& int sort) {
&&&&&&& String uriString = (uri != null) ? uri.toString() : &&;
&&&&&&& // TODO: we need to figure out whether we're viewing
&&&&&&& // DRM images in a better way.& Is there a constant
&&&&&&& // for content://drm somewhere??
&&&&&&& IImageList imageL
&&&&&&& if (uriString.startsWith(&content://drm&)) {
&&&&&&&&&&& imageList = ImageManager.allImages(
&&&&&&&&&&&&&&&&&&& cr, ImageManager.DataLocation.ALL,
&&&&&&&&&&&&&&&&&&& ImageManager.INCLUDE_DRM_IMAGES, sort);
&&&&&&& } else if (uriString.startsWith(&content://media/external/video&)) {
&&&&&&&&&&& imageList = ImageManager.allImages(
&&&&&&&&&&&&&&& cr, ImageManager.DataLocation.EXTERNAL,
&&&&&&&&&&&&&&& ImageManager.INCLUDE_VIDEOS, sort);
&&&&&&& } else if (isSingleImageMode(uriString)) {
&&&&&&&&&&& imageList = new SingleImageList(uri);
&&&&&&&&&&& ((SingleImageList) imageList).open(cr);
&&&&&&& } else {
&&&&&&&&&&& String bucketId = uri.getQueryParameter(&bucketId&);
&&&&&&&&&&& imageList = ImageManager.allImages(
&&&&&&&&&&&&&&& cr, ImageManager.DataLocation.ALL,
&&&&&&&&&&&&&&& ImageManager.INCLUDE_IMAGES, sort, bucketId);
&&&&&&& return imageL
&&& static boolean isSingleImageMode(String uriString) {
&&&&&&& return !uriString.startsWith(
&&&&&&&&&&&&&&& MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString())
&&&&&&&&&&&&&&& && !uriString.startsWith(
&&&&&&&&&&&&&&& MediaStore.Images.Media.INTERNAL_CONTENT_URI.toString());
&&& private static class EmptyImageList implements IImageList {
&&&&&&& public static final Creator&EmptyImageList& CREATOR =
&&&&&&&&&&&&&&& new Creator&EmptyImageList&() {
&&&&&&&&&&& public EmptyImageList createFromParcel(Parcel in) {
&&&&&&&&&&&&&&& return new EmptyImageList();
&&&&&&&&&&& }
&&&&&&&&&&& public EmptyImageList[] newArray(int size) {
&&&&&&&&&&&&&&& return new EmptyImageList[size];
&&&&&&&&&&& }
&&&&&&& };
&&&&&&& public void open(ContentResolver resolver) {
&&&&&&& public void close() {
&&&&&&& public void checkThumbnail(int index) {
&&&&&&& public void deactivate() {
&&&&&&& public HashMap&String, String& getBucketIds() {
&&&&&&&&&&& return new HashMap&String, String&();
&&&&&&& public int getCount() {
&&&&&&&&&&& return 0;
&&&&&&& public boolean isEmpty() {
&&&&&&&&&&&
&&&&&&& public IImage getImageAt(int i) {
&&&&&&&&&&&
&&&&&&& public IImage getImageForUri(Uri uri) {
&&&&&&&&&&&
&&&&&&& public boolean removeImage(IImage image) {
&&&&&&&&&&&
&&&&&&& public boolean removeImageAt(int i) {
&&&&&&&&&&&
&&&&&&& public int getImageIndex(IImage image) {
&&&&&&&&&&& throw new UnsupportedOperationException();
&&&&&&& public int describeContents() {
&&&&&&&&&&& return 0;
&&&&&&& public void writeToParcel(Parcel dest, int flags) {
&&& public static IImageList emptyImageList() {
&&&&&&& return new EmptyImageList();
&&& public static IImageList allImages(ContentResolver cr,
&&&&&&&&&&& DataLocation location, int inclusion, int sort) {
&&&&&&& return allImages(cr, location, inclusion, sort, null);
&&& public static IImageList allImages(ContentResolver cr,
&&&&&&&&&&& DataLocation location, int inclusion, int sort, String bucketId) {
&&&&&&& if (cr == null) {
&&&&&&&&&&&
&&&&&&& // false ==& don't require write access
&&&&&&& boolean haveSdCard = hasStorage(false);
&&&&&&& // use this code to merge videos and stills into the same list
&&&&&&& ArrayList&BaseImageList& l = new ArrayList&BaseImageList&();
&&&&&&& if (haveSdCard && location != DataLocation.INTERNAL) {
&&&&&&&&&&& if ((inclusion & INCLUDE_IMAGES) != 0) {
&&&&&&&&&&&&&&& l.add(new ImageList(
&&&&&&&&&&&&&&&&&&&&&&& STORAGE_URI, THUMB_URI, sort, bucketId));
&&&&&&&&&&& }
&&&&&&&&&&& if ((inclusion & INCLUDE_VIDEOS) != 0) {
&&&&&&&&&&&&&&& l.add(new VideoList(VIDEO_STORAGE_URI, sort, bucketId));
&&&&&&&&&&& }
&&&&&&& if (location == DataLocation.INTERNAL || location == DataLocation.ALL) {
&&&&&&&&&&& if ((inclusion & INCLUDE_IMAGES) != 0) {
&&&&&&&&&&&&&&& l.add(new ImageList(
&&&&&&&&&&&&&&&&&&&&&&& Images.Media.INTERNAL_CONTENT_URI,
&&&&&&&&&&&&&&&&&&&&&&& Images.Thumbnails.INTERNAL_CONTENT_URI,
&&&&&&&&&&&&&&&&&&&&&&& sort, bucketId));
&&&&&&&&&&& }
&&&&&&&&&&& if ((inclusion & INCLUDE_DRM_IMAGES) != 0) {
&&&&&&&&&&&&&&& l.add(new DrmImageList(
&&&&&&&&&&&&&&&&&&&&&&& DrmStore.Images.CONTENT_URI, sort, bucketId));
&&&&&&&&&&& }
&&&&&&& // Optimization: If some of the lists are empty, remove them.
&&&&&&& // If there is only one remaining list, return it directly.
&&&&&&& Iterator&BaseImageList& iter = l.iterator();
&&&&&&& while (iter.hasNext()) {
&&&&&&&&&&& BaseImageList sublist = iter.next();
&&&&&&&&&&& sublist.open(cr);
&&&&&&&&&&& if (sublist.isEmpty()) iter.remove();
&&&&&&&&&&& sublist.close();
&&&&&&& if (l.size() == 1) {
&&&&&&&&&&& BaseImageList list = l.get(0);
&&&&&&&&&&& list.open(cr);
&&&&&&&&&&&
&&&&&&& ImageListUber uber = new ImageListUber(
&&&&&&&&&&&&&&& l.toArray(new IImageList[l.size()]), sort);
&&&&&&& uber.open(cr);
&&& private static boolean checkFsWritable() {
&&&&&&& // Create a temporary file to see whether a volume is really writeable.
&&&&&&& // It's important not to put it in the root directory which may have a
&&&&&&& // limit on the number of files.
&&&&&&& String directoryName =
&&&&&&&&&&&&&&& Environment.getExternalStorageDirectory().toString() + &/DCIM&;
&&&&&&& File directory = new File(directoryName);
&&&&&&& if (!directory.isDirectory()) {
&&&&&&&&&&& if (!directory.mkdirs()) {
&&&&&&&&&&&&&&&
&&&&&&&&&&& }
&&&&&&& File f = new File(directoryName, &.probe&);
&&&&&&& try {
&&&&&&&&&&& // Remove stale file if any
&&&&&&&&&&& if (f.exists()) {
&&&&&&&&&&&&&&& f.delete();
&&&&&&&&&&& }
&&&&&&&&&&& if (!f.createNewFile()) {
&&&&&&&&&&&&&&&
&&&&&&&&&&& }
&&&&&&&&&&& f.delete();
&&&&&&&&&&&
&&&&&&& } catch (IOException ex) {
&&&&&&&&&&&
&&& public static boolean hasStorage() {
&&&&&&& return hasStorage(true);
&&& public static boolean hasStorage(boolean requireWriteAccess) {
&&&&&&& String state = Environment.getExternalStorageState();
&&&&&&& if (Environment.MEDIA_MOUNTED.equals(state)) {
&&&&&&&&&&& if (requireWriteAccess) {
&&&&&&&&&&&&&&& boolean writable = checkFsWritable();
&&&&&&&&&&&&&&&
&&&&&&&&&&& } else {
&&&&&&&&&&&&&&&
&&&&&&&&&&& }
&&&&&&& } else if (!requireWriteAccess
&&&&&&&&&&&&&&& && Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
&&&&&&&&&&&
&&& private static Cursor query(ContentResolver resolver, Uri uri,
&&&&&&&&&&& String[] projection, String selection, String[] selectionArgs,
&&&&&&&&&&& String sortOrder) {
&&&&&&& try {
&&&&&&&&&&& if (resolver == null) {
&&&&&&&&&&&&&&&
&&&&&&&&&&& }
&&&&&&&&&&& return resolver.query(
&&&&&&&&&&&&&&&&&&& uri, projection, selection, selectionArgs, sortOrder);
&&&&&&&& } catch (UnsupportedOperationException ex) {
&&&&&&&&&&&
&&& public static boolean isMediaScannerScanning(ContentResolver cr) {
&&&&&&& boolean result =
&&&&&&& Cursor cursor = query(cr, MediaStore.getMediaScannerUri(),
&&&&&&&&&&&&&&& new String [] {MediaStore.MEDIA_SCANNER_VOLUME},
&&&&&&&&&&&&&&& null, null, null);
&&&&&&& if (cursor != null) {
&&&&&&&&&&& if (cursor.getCount() == 1) {
&&&&&&&&&&&&&&& cursor.moveToFirst();
&&&&&&&&&&&&&&& result = &external&.equals(cursor.getString(0));
&&&&&&&&&&& }
&&&&&&&&&&& cursor.close();
&&& public static String getLastImageThumbPath() {
&&&&&&& return Environment.getExternalStorageDirectory().toString() +
&&&&&&&&&&&&&& &/DCIM/.thumbnails/image_last_thumb&;
&&& public static String getLastVideoThumbPath() {
&&&&&&& return Environment.getExternalStorageDirectory().toString() +
&&&&&&&&&&&&&& &/DCIM/.thumbnails/video_last_thumb&;
//--------------------------------------------------------------------------------------------------------------------
禁止.thumbnails自动生成
~/.thumbnails
避免生成tumbnails文件夹的方法是在电脑上新建一个txt文件,并把这个文本文件的后缀名.txt去掉,电脑会提示“如果改变文件扩展名,可能导致文件不可用,确实要更改吗”这样的提示,点击确定,把得到的这个文件拷贝到TF卡的根目录,在安卓系统下将这个文件重命名为.nomedia(注意!nomedia单词前面有一个&.&)因windows系统不支持新建.与_开头的文件,所以重命名必须在WM系统下进行。按照以上步骤,DCIM文件夹下就不会再生成tumbnails文件夹。
~/.thumbnails
你打开看这个文件夹,是不是很奇怪。有好多你浏览过的图片,包括u盘等移动介质。还有预览的图片也在其中,随着时间可能达到1~2G
有些个人隐私,也跑这个文件夹中了。比如我喜欢使用 ecryptfs-ulit 一个商用级别(免费)的加密数据层。这下也白干了。
所以要对付它。删除它是不可能的,有些程序会自动生成它作为临时文件夹。可是却忘了删它……
/tmp是系统指定的临时文件夹,有个很好的特性——关闭系统会自动清空遮这个文件夹。
当然我把它扔到内存中,更保护硬盘。那只要启动前把/tmp 指定为tmpfs文件系统即可
把.thumbnails 删除了。复制/tmp文件夹 作为链接到~目录,命名为.thumbnails
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:284606次
积分:4296
积分:4296
排名:第5472名
原创:136篇
转载:106篇
评论:44条
(2)(1)(3)(7)(3)(6)(3)(5)(2)(9)(15)(22)(8)(1)(6)(6)(2)(16)(5)(1)(9)(8)(18)(3)(10)(6)(3)(20)(5)(5)(9)(3)(7)(4)(2)(4)(4)}

我要回帖

更多关于 安卓 获取路由器ip 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信