我想要做的事情很简单,就是从相册中选择一张图片,并将选定的图片上传到我的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();
}
}
}
任何帮助都将不胜感激。