out of memory - Android take more picture from camera "Couldn't allocate byte array for JPEG data" -


i'm trying take picture in sequence android, timelapse.

i call

 camera.takepicture(null, null, jpegcallback); 

and jpegcallback is:

picturecallback jpegcallback = new picturecallback() {     public void onpicturetaken(byte[] data, camera camera) {         time++;         photocounter.settext(string.valueof(time));          saveimagetask sav = new saveimagetask(filenameind++);         sav.execute(data);         resetcam();         log.d(tag, "onpicturetaken - jpeg");     } };  private class saveimagetask extends asynctask<byte[], void, void> {     int name;    saveimagetask(int name){       this.name = name;   }      @override     protected void doinbackground(byte[]... data) {         fileoutputstream outstream = null;          // write sd card         try {             file sdcard = environment.getexternalstoragedirectory();             file dir = new file (sdcard.getabsolutepath() + "/timelaps");             dir.mkdirs();                java.text.numberformat nf = new java.text.decimalformat("000000");                string filename = (nf.format(name)+".jpg");             file outfile = new file(dir, filename);               outstream = new fileoutputstream(outfile);              outstream.write(data[0]);               outstream.flush();             outstream.close();              log.d(tag, "onpicturetaken - wrote bytes: " + data.length + " " + outfile.getabsolutepath());              refreshgallery(outfile);         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } {         }         return null;     }      @override     protected void onpostexecute(void avoid) {         super.onpostexecute(avoid);       } } 

but after taking 20-30 picture get:

e/camera-jni ] couldn't allocate byte array jpeg data

and data picturecallback null.

why happens?? memory full?? how can free memory??

thank much


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -