13

Is there any plugin for cordova (android) refreshing gallery?

  • Capturing video using cordova plugin cordova-plugin-media-capture it saves the video to default sdcard path(gallery).

  • Now i am moving the file from sdcard path to my application directory path(com.test.app).

  • File moved successfully ,my application and functionality working fine.

Issue : After moving file there is still a video thumbnail with name No thumbnail . when i click on thumbnail , this displays a alert The file can not be reproduced this is because it has been moved from gallery path to application path.if I restart my phone there is no video thumbnail because it is refreshing the sdcard/gallery. What i want is to refresh the gallery after moving file.

Code for moving file

Plugin used: cordova-plugin-file

var fileURI="file:/storage/emulated/0/DCIM/Camera/VID_20161022_121221.mp4";
var newFileUri='file:///mnt/sdcard/Android/data/com.test.app/myvideo/'; 
var newFileName='uservideoname.mp4';        
        window.resolveLocalFileSystemURL(fileURI, 
        function (fileEntry) {
            window.resolveLocalFileSystemURL(newFileUri,
                function (dirEntry) {
                    // move the file to a new directory and rename it
                    fileEntry.moveTo(dirEntry, newFileName, function () {
                     // successfully moved
                    },
                    function (e) {
                    console.log(e);
                    });
                },
                function (e) {
                console.log(e);
                });

        },
        function (e){ 
            console.log(e);
        });
        }
Deepak
  • 523
  • 4
  • 24
  • It looks like you'll need a plugin for that: http://stackoverflow.com/questions/8700256/how-to-update-thumbnails-preview-of-android-gallery-after-image-edited – daserge Oct 25 '16 at 13:52
  • I tried for media scanner https://github.com/peteygao/MediaScannerPlugin and https://github.com/saurabhgupta050890/Media-Refresher-Cordova . I get error `Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED` – Deepak Oct 27 '16 at 09:45
  • Regarding that error - looks like you'll need to rewrite the plugin for Android >= 4.4: http://stackoverflow.com/a/24072611/4177762 – daserge Oct 27 '16 at 10:00
  • Changed ACTION_MEDIA_MOUNTED to ACTION_MEDIA_SCANNER_SCAN_FILE for kitkat and above works fine. but my problem still remain same.there is same thumbnail of 0 byte after scanning.@daserge thanks for your time – Deepak Oct 27 '16 at 10:38
  • See if this helps: https://github.com/apache/cordova-plugin-file-transfer/pull/165 – daserge Nov 03 '16 at 10:12

1 Answers1

0

May this will help you.Happy coding

https://build.phonegap.com/plugins/2725
Dharmishtha
  • 1,313
  • 10
  • 21