Options mOptions; public DecodeCanceller(Options options) { mOptions = options; } public void onCancel() { mOptions.requestCancelDecode(); } } public static Bitmap requestDecode(JobContext jc, final String filePath, Options options) { if (options == null) options = new Options(); jc.setCancelListener(new DecodeCanceller(options)); return ensureGLCompatibleBitmap( BitmapFactory.decodeFile(filePath, options)); } public static Bitmap requestDecode(JobContext jc, FileDescriptor fd, Options options) { if (options == null) options = new Options(); jc.setCancelListener(new DecodeCanceller(options));