protected void setWallpaper(Uri uri, final boolean finishActivityWhenDone) { int rotation = getRotationFromExif(this, uri); BitmapCropTask cropTask = new BitmapCropTask(this, uri, null, rotation, 0, 0, true, false, null); final Point bounds = cropTask.getImageBounds(); Runnable onEndCrop = new Runnable() { public void run() { updateWallpaperDimensions(bounds.x, bounds.y); if (finishActivityWhenDone) { setResult(Activity.RESULT_OK); finish(); } } }; cropTask.setOnEndRunnable(onEndCrop); cropTask.setNoCrop(true); cropTask.execute(); }