小编Mar*_*sar的帖子

使用CursorLoader和LoaderManager从Android应用程序中检索图像

目前我正在使用getContentResolver().query()/ managedQuery()来获取光标以从图库应用程序中检索图像.因为我正在使用的API部分弃用,所以我想将CursorLoader与LoaderManager一起使用.

/**
 * Creates a cursor to access the content defined by the image uri for API
 * version 11 and newer.
 * 
 * @return The created cursor.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private Cursor createCursorHoneycomb() {
    String[] projection = {
            MediaStore.Images.Media.DATA
    };
    Cursor cursor = getContentResolver().query(imageUri, projection, null, null, null);

    return cursor;
}

/**
 * Creates a cursor to access the content defined by the image uri from API
 * version 8 to 10.
 * 
 * @return The created cursor.
 */ …
Run Code Online (Sandbox Code Playgroud)

android android-cursor android-loadermanager android-cursorloader android-cursoradapter

2
推荐指数
1
解决办法
6886
查看次数