當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageColumns類代碼示例

本文整理匯總了Java中android.provider.MediaStore.Images.ImageColumns的典型用法代碼示例。如果您正苦於以下問題:Java ImageColumns類的具體用法?Java ImageColumns怎麽用?Java ImageColumns使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImageColumns類屬於android.provider.MediaStore.Images包,在下文中一共展示了ImageColumns類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryOrientationForImage

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
protected int queryOrientationForImage(long id, CancellationSignal signal) {
    final ContentResolver resolver = getContext().getContentResolver();

    Cursor cursor = null;
    try {
        cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                ImageOrientationQuery.PROJECTION, ImageColumns._ID + "=" + id, null, null);
        if (cursor.moveToFirst()) {
            return cursor.getInt(ImageOrientationQuery.ORIENTATION);
        } else {
            Log.w(TAG, "Missing orientation data for " + id);
            return 0;
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:18,代碼來源:StorageProvider.java

示例2: getRealFilePath

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/**
 * Try to return the absolute file path from the given Uri
 * 
 * @param context
 * @param uri
 * @return the file path or null
 */
public static String getRealFilePath( final Context context, final Uri uri ) {

	if ( null == uri ) return null;

	final String scheme = uri.getScheme();
	String data = null;

	if ( scheme == null )
		data = uri.getPath();
	else if ( ContentResolver.SCHEME_FILE.equals( scheme ) ) {
		data = uri.getPath();
	} else if ( ContentResolver.SCHEME_CONTENT.equals( scheme ) ) {
		Cursor cursor = context.getContentResolver().query( uri, new String[] { ImageColumns.DATA }, null, null, null );
		if ( null != cursor ) {
			if ( cursor.moveToFirst() ) {
				int index = cursor.getColumnIndex( ImageColumns.DATA );
				if ( index > -1 ) {
					data = cursor.getString( index );
				}
			}
			cursor.close();
		}
	}
	return data;
}
 
開發者ID:viseator,項目名稱:MontageCam,代碼行數:33,代碼來源:IOUtils.java

示例3: getRealFilePath

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/** 根據Uri獲取圖片文件的絕對路徑 */
public static String getRealFilePath(Context context, Uri uri) {
	if (null == uri) {
		return null;
	}

	final String scheme = uri.getScheme();
	String data = null;
	if (scheme == null) {
		data = uri.getPath();
	} else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
		data = uri.getPath();
	} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
		Cursor cursor = context.getContentResolver().query(uri, new String[] { ImageColumns.DATA }, null, null, null);
		if (null != cursor) {
			if (cursor.moveToFirst()) {
				int index = cursor.getColumnIndex(ImageColumns.DATA);
				if (index > -1) {
					data = cursor.getString(index);
				}
			}
			cursor.close();
		}
	}
	return data;
}
 
開發者ID:qiaop,項目名稱:android-post,代碼行數:27,代碼來源:FileUtils.java

示例4: photosCursorToSelection

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
public static PhotoUpload photosCursorToSelection(Uri contentUri,
		Cursor cursor) {
	PhotoUpload item = null;

	try {
		File file = new File(cursor.getString(cursor
				.getColumnIndexOrThrow(ImageColumns.DATA)));
		if (file.exists()) {
			item = PhotoUpload
					.getSelection(contentUri, cursor.getInt(cursor
							.getColumnIndexOrThrow(ImageColumns._ID)));
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

	return item;
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:19,代碼來源:MediaStoreCursorHelper.java

示例5: getCurrent

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/**
 * 獲取最近使用的照片
 * 
 * @return
 */
public List<PhotoModel> getCurrent() {
    Cursor cursor = resolver.query(Media.EXTERNAL_CONTENT_URI, new String[] {
            ImageColumns.DATA,
            ImageColumns.DATE_ADDED, ImageColumns.SIZE
    }, null, null, ImageColumns.DATE_ADDED);
    if (cursor == null || !cursor.moveToNext())
        return new ArrayList<PhotoModel>();
    List<PhotoModel> photos = new ArrayList<PhotoModel>();
    cursor.moveToLast();
    do {
        if (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());
    IOUtils.closeQuietly(cursor);
    return photos;
}
 
開發者ID:umeng,項目名稱:umeng_community_android,代碼行數:26,代碼來源:AlbumController.java

示例6: getAlbum

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/**
 * 獲取某個相冊中的所有圖片
 * 
 * @param name
 * @return
 */
public List<PhotoModel> getAlbum(String name) {
    Cursor cursor = resolver.query(Media.EXTERNAL_CONTENT_URI, new String[] {
            ImageColumns.BUCKET_DISPLAY_NAME,
            ImageColumns.DATA, ImageColumns.DATE_ADDED, ImageColumns.SIZE
    }, "bucket_display_name = ?",
            new String[] {
                name
            }, ImageColumns.DATE_ADDED);
    if (cursor == null || !cursor.moveToNext())
        return new ArrayList<PhotoModel>();
    List<PhotoModel> photos = new ArrayList<PhotoModel>();
    cursor.moveToLast();
    do {
        if (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());
    IOUtils.closeQuietly(cursor);
    return photos;
}
 
開發者ID:umeng,項目名稱:umeng_community_android,代碼行數:30,代碼來源:AlbumController.java

示例7: getContentValuesForData

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
public static ContentValues getContentValuesForData(String title,
        long date, Location location, int orientation, long jpegLength,
        String path, int width, int height, String mimeType) {

    File file = new File(path);
    long dateModifiedSeconds = TimeUnit.MILLISECONDS.toSeconds(file.lastModified());

    ContentValues values = new ContentValues(11);
    values.put(ImageColumns.TITLE, title);
    values.put(ImageColumns.DISPLAY_NAME, title + JPEG_POSTFIX);
    values.put(ImageColumns.DATE_TAKEN, date);
    values.put(ImageColumns.MIME_TYPE, mimeType);
    values.put(ImageColumns.DATE_MODIFIED, dateModifiedSeconds);
    // Clockwise rotation in degrees. 0, 90, 180, or 270.
    values.put(ImageColumns.ORIENTATION, orientation);
    values.put(ImageColumns.DATA, path);
    values.put(ImageColumns.SIZE, jpegLength);

    setImageSize(values, width, height);

    if (location != null) {
        values.put(ImageColumns.LATITUDE, location.getLatitude());
        values.put(ImageColumns.LONGITUDE, location.getLongitude());
    }
    return values;
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:27,代碼來源:Storage.java

示例8: getMimeTypeForMedia

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
public static String getMimeTypeForMedia(ContentResolver cr, int id,
		boolean isImage) {
	Cursor cursor;
	
	if(isImage)
		cursor = cr.query(
				MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String [] {MediaStore.Images.Media.MIME_TYPE}, ImageColumns._ID+" = ?", 
                new String [] { String.valueOf(id) }, null);
	else
		cursor = cr.query(
				MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                new String [] {MediaStore.Video.Media.MIME_TYPE}, VideoColumns._ID+" = ?", 
                new String [] { String.valueOf(id) }, null);
		
	try {
		if(!cursor.moveToFirst())
			return null;
		
		return cursor.getString(0);
	}
	finally {
		cursor.close();
	}
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:26,代碼來源:Util.java

示例9: getDataFilepathForMedia

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
public static String getDataFilepathForMedia(ContentResolver cr, int id, boolean isImage)
{
	Cursor cursor;
	
	if(isImage)
		cursor = cr.query(
				MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String [] {MediaStore.Images.Media.DATA}, ImageColumns._ID+" = ?", 
                new String [] { String.valueOf(id) }, null);
	else
		cursor = cr.query(
				MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                new String [] {MediaStore.Video.Media.DATA}, VideoColumns._ID+" = ?", 
                new String [] { String.valueOf(id) }, null);
		
	try {
		if(!cursor.moveToFirst())
			return null;
		
		return cursor.getString(0);
	}
	finally {
		cursor.close();
	}
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:26,代碼來源:Util.java

示例10: LocalAlbum

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
public LocalAlbum(Path path, GalleryApp application, int bucketId,
        boolean isImage, String name) {
    super(path, nextVersionNumber());
    mApplication = application;
    mResolver = application.getContentResolver();
    mBucketId = bucketId;
    mName = name;
    mIsImage = isImage;

    if (isImage) {
        mWhereClause = ImageColumns.BUCKET_ID + " = ?";
        mOrderClause = ImageColumns.DATE_TAKEN + " DESC, "
                + ImageColumns._ID + " DESC";
        mBaseUri = Images.Media.EXTERNAL_CONTENT_URI;
        mProjection = LocalImage.PROJECTION;
        mItemPath = LocalImage.ITEM_PATH;
    } else {
        mWhereClause = VideoColumns.BUCKET_ID + " = ?";
        mOrderClause = VideoColumns.DATE_TAKEN + " DESC, "
                + VideoColumns._ID + " DESC";
        mBaseUri = Video.Media.EXTERNAL_CONTENT_URI;
        mProjection = LocalVideo.PROJECTION;
        mItemPath = LocalVideo.ITEM_PATH;
    }

    mNotifier = new ChangeNotifier(this, mBaseUri, application);
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:28,代碼來源:LocalAlbum.java

示例11: getTrueFilename

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/**
 * Gets the actual filename for a Uri from Gallery's ContentProvider.
 */
private static String getTrueFilename(Context context, Uri src) {
    if (context == null || src == null) {
        return null;
    }
    final String[] trueName = new String[1];
    querySource(context, src, new String[] {
            ImageColumns.DATA
    }, new ContentResolverQueryCallback() {
        @Override
        public void onCursorResult(Cursor cursor) {
            trueName[0] = new File(cursor.getString(0)).getName();
        }
    });
    return trueName[0];
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:19,代碼來源:SaveImage.java

示例12: getContentValues

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
private static ContentValues getContentValues(Context context, Uri sourceUri,
                                              File file, long time) {
    final ContentValues values = new ContentValues();

    time /= 1000;
    values.put(Images.Media.TITLE, file.getName());
    values.put(Images.Media.DISPLAY_NAME, file.getName());
    values.put(Images.Media.MIME_TYPE, "image/jpeg");
    values.put(Images.Media.DATE_TAKEN, time);
    values.put(Images.Media.DATE_MODIFIED, time);
    values.put(Images.Media.DATE_ADDED, time);
    values.put(Images.Media.ORIENTATION, 0);
    values.put(Images.Media.DATA, file.getAbsolutePath());
    values.put(Images.Media.SIZE, file.length());

    final String[] projection = new String[] {
            ImageColumns.DATE_TAKEN,
            ImageColumns.LATITUDE, ImageColumns.LONGITUDE,
    };

    SaveImage.querySource(context, sourceUri, projection,
            new ContentResolverQueryCallback() {

                @Override
                public void onCursorResult(Cursor cursor) {
                    values.put(Images.Media.DATE_TAKEN, cursor.getLong(0));

                    double latitude = cursor.getDouble(1);
                    double longitude = cursor.getDouble(2);
                    // TODO: Change || to && after the default location
                    // issue is fixed.
                    if ((latitude != 0f) || (longitude != 0f)) {
                        values.put(Images.Media.LATITUDE, latitude);
                        values.put(Images.Media.LONGITUDE, longitude);
                    }
                }
            });
    return values;
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:40,代碼來源:SaveImage.java

示例13: getCurrent

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/** 獲取最近照片列表 */
public List<PhotoModel> getCurrent() {
	Cursor cursor = resolver.query(Media.EXTERNAL_CONTENT_URI, new String[] { ImageColumns.DATA,
			ImageColumns.DATE_ADDED, ImageColumns.SIZE }, null, null, ImageColumns.DATE_ADDED);
	if (cursor == null || !cursor.moveToNext())
		return new ArrayList<PhotoModel>();
	List<PhotoModel> photos = new ArrayList<PhotoModel>();
	cursor.moveToLast();
	do {
		if (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;
}
 
開發者ID:FrankSunnyvale,項目名稱:cordova-imagePicker,代碼行數:18,代碼來源:AlbumController.java

示例14: getAlbum

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/** 獲取對應相冊下的照片 */
public List<PhotoModel> getAlbum(String name) {
	Cursor cursor = resolver.query(Media.EXTERNAL_CONTENT_URI, new String[] { ImageColumns.BUCKET_DISPLAY_NAME,
			ImageColumns.DATA, ImageColumns.DATE_ADDED, ImageColumns.SIZE }, "bucket_display_name = ?",
			new String[] { name }, ImageColumns.DATE_ADDED);
	if (cursor == null || !cursor.moveToNext())
		return new ArrayList<PhotoModel>();
	List<PhotoModel> photos = new ArrayList<PhotoModel>();
	cursor.moveToLast();
	do {
		if (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;
}
 
開發者ID:FrankSunnyvale,項目名稱:cordova-imagePicker,代碼行數:19,代碼來源:AlbumController.java

示例15: getRealFilePath

import android.provider.MediaStore.Images.ImageColumns; //導入依賴的package包/類
/**
 * 獲取圖片的存儲路徑;
 * 
 * @param context
 * @param uri
 * @return
 */
public static String getRealFilePath(Context context, Uri uri) {
	if (null == uri)
		return null;
	String scheme = uri.getScheme();
	String data = null;
	if (scheme == null)
		data = uri.getPath();
	else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
		data = uri.getPath();
	} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
		Cursor cursor = context.getContentResolver().query(uri, new String[] { ImageColumns.DATA }, null, null,
				null);
		if (null != cursor) {
			if (cursor.moveToFirst()) {
				int index = cursor.getColumnIndex(ImageColumns.DATA);
				if (index > -1) {
					data = cursor.getString(index);
				}
			}
			cursor.close();
		}
	}
	return data;
}
 
開發者ID:vivdaxiang,項目名稱:DaXiangLibrary,代碼行數:32,代碼來源:BitmapUtils.java


注:本文中的android.provider.MediaStore.Images.ImageColumns類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。