我正在尝试向目前市场上的应用程序发布关键更新.我需要查询MediaStore中的缩略图,并将缩略图加载到GridView中.到目前为止一切都很好,现在我只需要根据我的内容(缩略图的路径)获取用户外部存储上的实际全尺寸图像的路径.每当用户点击缩略图,共享,查看,移动和删除时,我都需要能够执行4个操作...但我不能仅使用缩略图路径执行任何操作,我已经尝试了所有内容,但没有工作:/.以下是我在下面的实施片段,对此的任何帮助或指导将不胜感激!
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
int columnIndex = 0;
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, null);
if(cursor != null){
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition(position);
imagePath = cursor.getString(columnIndex);
FileInputStream is = null;
BufferedInputStream bis = null;
try{
is = new FileInputStream(new File(imagePath));
bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
useThisBitmap = Bitmap.createScaledBitmap(bitmap, parent.getWidth(), parent.getHeight(), true);
bitmap.recycle();
}catch(Exception e){
//Try to recover
}
finally{
try{
if(bis != null){
bis.close();
} …Run Code Online (Sandbox Code Playgroud)