c# - Picture appears only after restart the device -
i have android-app takes pictures , saves them in external storage ("dcim/cameras"). pictures appear after restarting handy. there kind of update or way around this?
my source-code saving image:
var dir = android.os.environment.getexternalstoragepublicdirectory(android.os.environment.directorydcim); var pictures = dir.absolutepath + "/camera"; string name = system.datetime.now.tostring("yyyymmdd_hhmmssfff") + ".jpg"; string filepath = system.io.path.combine(pictures, name); filestream output; bitmap bitmap = bitmapfactory.decodebytearray(imagedata, 0, imagedata.length); try { output = new filestream(filepath, filemode.create); bitmap.compress(bitmap.compressformat.jpeg, 100, output); output.close(); //static class contains methode mediascannerconnection.scanfile mediagalleryhelper.addfiletogallery(name); } catch (system.exception ex) { system.console.writeline(ex.tostring()); }
you have let photo gallery know new photo has been added. can use below code that:
this.sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.parse("file://" + filepath))); where 'this' activity.
Comments
Post a Comment