1

Yes I saw the other post on this - nothing worked for me. Here's what I'm doing

Created a new Java Class

public abstract class ImageHelper {

    //Post task
    public static byte [] taskImage1;

}

First activity, Get image 1 + add to Byte array

    ImageButton Pic1s = (ImageButton) findViewById(R.id.pic1);
    Drawable drawable1 = Pic1s.getDrawable();
    Bitmap bitmap1= ((BitmapDrawable)drawable1).getBitmap();
    ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
    bitmap1.compress(Bitmap.CompressFormat.PNG, 100, baos1);
    byte[] b1 = baos1.toByteArray();
    ImageHelper.taskImage1 = b1;

Second activity

byte[] b1 = ImageHelper.taskImage1;
Bitmap bmp1 = BitmapFactory.decodeByteArray(b1, 0, b1.length);

ParseObject myTask = new ParseObject("Task");
myTask.put("imageFile1", bmp1);
myTask.saveInBackground()

It doesn't work, the image doesn't upload to Parse, I also tried to display the image in the second activity as a test and that didn't work either

To display the image I tried this :

    byte[] b1 = ImageHelper.taskImage1;
    Bitmap bmp = BitmapFactory.decodeByteArray(b1, 0, b1.length);
    ImageView image = (ImageView) findViewById(R.id.bg);

    image.setImageBitmap(Bitmap.createScaledBitmap(bmp, image.getWidth(),
            image.getHeight(), false));
gprathour
  • 14,813
  • 5
  • 66
  • 90
  • 3
    You can just save the image in external storage and then access it in other activities. – Kaushal28 Jun 23 '17 at 12:45
  • 2
    The cache is for this type of thing. Save it there: https://developer.android.com/reference/android/content/Context.html#getCacheDir() – Kuffs Jun 23 '17 at 12:49
  • please refer this link contains multiple solution for the problem you raised https://stackoverflow.com/questions/11519691/passing-image-from-one-activity-another-activity – Shivang Agarwal Jun 23 '17 at 12:54
  • "Passing an image from one activity to the other" -- in general, you do not want to do this, as this is memory-intensive and may cause your app to crash with an `OutOfMemoryError` or `FAILED BINDER TRANSACTION`. – CommonsWare Jun 23 '17 at 12:57

0 Answers0