![](/img/trans.png)
[英]Android - How to open a specific folder in a gallery using an implicit intent?
[英]How to open gallery intent using Ucrop library in android studio?
我正在使用此处提供的库https://github.com/Yalantis/uCrop 。
我想在使用裁剪选项功能单击按钮时直接打开图库意图,但是我该怎么办呢?
目前,我正在这样做
public void onclickbutton (View view) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
if (checkPermissionREAD_EXTERNAL_STORAGE(this)) {
startActivityForResult(intent, GALLERY_INTENT);
}
}
在活动结果中
if (requestcode == GALLERY_INTENT && resultcode == RESULT_OK)
{
uri = data.getData();
UCrop.of(uri, uri)
.withAspectRatio(16, 9)
.withMaxResultSize(500, 500)
.start(this);
}
再次处于非活动状态
if (resultcode == RESULT_OK && requestcode == UCrop.REQUEST_CROP) {
final Uri resultUri = UCrop.getOutput(data);
Toast.makeText(this, resultUri.toString(), Toast.LENGTH_SHORT).show();
} else if (resultcode == UCrop.RESULT_ERROR) {
final Throwable cropError = UCrop.getError(data);
}
请帮我哪里出问题了..
您需要更改您传递的uri的Onactivity结果,您必须传递源uri和目标uri。 如下图所示
UCrop.of(sourceUri, destinationUri)
.withAspectRatio(16, 9)
.withMaxResultSize(maxWidth, maxHeight)
.start(context);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.