yegong0214
if (data != null) {    
    Uri uri = data.getData();    
    if (!TextUtils.isEmpty(uri.getAuthority())) {    
        Cursor cursor = getContentResolver().query(uri,  
                new String[] { MediaStore.Images.Media.DATA },null, null, null);    
        if (null == cursor) {    
            Toast.makeText(this, "图片没找到", Toast.LENGTH_SHORT).show();    
            return;    
        }    
        cursor.moveToFirst();    
        path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));  
        cursor.close();    
    } else {    
        path = uri.getPath();    
    }    
}else{    
    Toast.makeText(this, "图片没找到", Toast.LENGTH_SHORT).show();    
    return;    
}   


在onActivityResult的方法里 做如上的操作 即可,具体原因有待考证。

 

分类:

技术点:

相关文章:

  • 2021-06-25
  • 2021-12-17
  • 2021-12-09
  • 2022-01-11
  • 2022-01-07
  • 2022-12-23
  • 2022-01-15
猜你喜欢
  • 2021-04-26
  • 2021-06-27
  • 2022-02-23
  • 2021-09-20
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案