【发布时间】:2017-08-04 08:09:42
【问题描述】:
基本上我想做的就是从图库中挑选一张图片,然后将同一张图片上传到我的 Cloudinary 帐户,我已经看过 Cloudinary 的文档,但我不太了解它是如何工作的,因此不知道如何在我的代码中实现它。
这是我获取信息的链接,以防有人需要... https://github.com/cloudinary/cloudinary_java/tree/master/cloudinary-android
这就是我目前所拥有的......
upload_image.class
public class edit_profile_activity extends AppCompatActivity
{
private static int RESULT_LOAD_IMG = 1;
String imgDecodableString;
public void loadImagefromGallery(View view)
{
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
try
{
if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK && null != data)
{
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imgDecodableString = cursor.getString(columnIndex);
cursor.close();
ImageView imgView = (ImageView) findViewById(R.id.circleImageView );
imgView.setImageBitmap(BitmapFactory.decodeFile(imgDecodableString));
} else {
Toast.makeText(this, "You haven't picked Image",Toast.LENGTH_LONG).show();
}
} catch (Exception e)
{
Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG) .show();
}
}
}
任何帮助将不胜感激
【问题讨论】:
-
阅读他们明确提到的文档
-
@jitesh mohite 我已经尝试实现该代码,但它不起作用:/
-
它给出了什么错误
标签: android android-studio cloudinary