本文介绍了Ucrop onActivityMethod不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ucrop库中使用下面的代码,并且显示出裁剪窗口.

I used below code from ucrop library and crop window is showing up.

 Uri destinationUri = Uri.fromFile(new File(myContext.getCacheDir(), "IMG_" + System.currentTimeMillis()));
            UCrop.of(sourceUri, destinationUri)
                     .withMaxResultSize(maxWidth, maxHeight)
                    .start(myContext);

但是,控件不在onActivityResult方法内部.如果/否则两者均不起作用.

but, control is not going inside onActivityResult method. If/Else both not working.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
        final Uri resultUri = UCrop.getOutput(data);
    } else if (resultCode == UCrop.RESULT_ERROR) {
        final Throwable cropError = UCrop.getError(data);
    }
}

任何主意怎么了,我错过了什么吗?

Any idea whats wrong, did I missed something?

推荐答案

Uri destinationUri = Uri.fromFile(new File(myContext.getCacheDir(), "IMG_" + System.currentTimeMillis()));
                UCrop.of(sourceUri, destinationUri)
                .withMaxResultSize(1080, 768) // any resolution you want
                .start(mContext, YourFragment/YourActivity.this);

这篇关于Ucrop onActivityMethod不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 01:05