I downloaded one image from server in local network using Glide in AsyncTask. In postExecute I tried to display the downloaded bitmap and it worked fine. But when I convert the bitmap into Pix object and pass it to another activity, the passed Pix object is Null. Below is my code
public void onResponse(String s) { //onResponse of a Volley Request
progressDialog.dismiss();
if (s.equals("OK")) {
Toast.makeText(ImageUploadDialog.this, "Uploaded Successful", Toast.LENGTH_LONG).show();
final ImageView image = (ImageView) findViewById(R.id.myImageView);
final Bitmap[] bmp = {null};
new AsyncTask<Void, Void, Void>() {
private static final String TAG = "STARTING_ACTIVITY";
@Override
protected Void doInBackground(Void... params) {
Looper.prepare();
try {
bmp[0] = Glide.
with(ImageUploadDialog.this).
asBitmap().
load("http://192.168.0.8:80/static/images/result.png").
into(1024, 666).
get();
} catch (final ExecutionException e) {
Log.e(TAG, e.getMessage());
} catch (final InterruptedException e) {
Log.e(TAG, e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void dummy) {
if (null != bmp[0]) {
// The full bitmap should be available here
//image.setImageBitmap(bmp[0]);
Log.d(TAG, "Image loaded");
Pix pix = ReadFile.readBitmap(bmp[0]);
Pix copiedPix = pix.copy();
Intent result = new Intent();
result.putExtra(UPLOAD_IMAGE, true);
result.putExtra(EXTRA_NATIVE_PIX, copiedPix.getNativePix());
result.putExtra(OCRActivity.EXTRA_USE_ACCESSIBILITY_MODE, accessibilityMode);
setResult(RESULT_OK, result);
finish();
};
}
}.execute();