0

I want to add an audio file to an image. So when someone gets that image he can extract the sound from it. I think we can add additional data to image header. But I don't know how to do that sort of header processing in Android. Can you please guide me...

Optimus
  • 415
  • 4
  • 19

1 Answers1

1

Using the below code you can add a small comment to the JPEG header in Android. It's only for JPEG.

final static String EXIF_TAG = "UserComment";


public static boolean setComment(String imagePath, String comment) {    
        try {
            ExifInterface exif = new ExifInterface(imagePath);
            exif.setAttribute(EXIF_TAG, comment);
            exif.saveAttributes();               
        } catch (IOException e) {
            e.printStackTrace();                
        }
        return true;

    }

But the problem is you can't put a audio file there because the data stream is way too big to fit in to the header.

Optimus
  • 415
  • 4
  • 19