I am trying to use Biokys crop image library within my AsyncTask class and for some reason when trying to start the crop image class for a result, I get an error.
I have looked up what would be causing this and people have suggested that you should use:
YourClassName.this.startActivityForResult(Intent, RESULT_CODE);
But this isn't working for me.
If someone would be able to explain why this is happening, would be much appreciated.
Class:
private void runCropImage() {
Intent intent = new Intent(context, CropImage.class);
// tell CropImage activity to look for image to crop
Bitmap filePath = bmImg;
intent.putExtra(CropImage.IMAGE_PATH, filePath);
// allow CropImage activity to rescale image
intent.putExtra(CropImage.SCALE, true);
// if the aspect ratio is fixed to ratio 3/2
intent.putExtra(CropImage.ASPECT_X, 3);
intent.putExtra(CropImage.ASPECT_Y, 2);
// start activity CropImage with certain request code and listen
// for result
SetWallpaperAsync.this.startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);
}
Instead of SetWallpaperAsync.this
use (Activity) context
like this:
((Activity) context).startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);