Search code examples
nativescriptnativescript-angularnativescript-camera

saveToFile not showing images into gallery


I created a nativescript app for camara related app. I am taking a photo using nativescript-camara module.

once user take a photo I am showing that image preview, as well as user can rename that image name. When user save that image I stored into a specific folder and removing preview image which stored by nativescript-camara module.

after that, i can see that image in the gallery but not the original image, I can only blank image in the gallery. I also checked that image is exist on that location where is saved it. That means, Image saving work perfects but not showing that image in the gallery immediately. After 5-10 minutes i can see that image in gallery. But not an immediately.

here is more details with images https://github.com/NativeScript/nativescript-camera/issues/222


Solution

  • Finally! i solved this issue, I scanned media and its done. Here is my code.

    var callback = new android.media.MediaScannerConnection.OnScanCompletedListener({
          onScanCompleted: function (path, uri) {
              console.log(path)
            }
        });
    
        android.media.MediaScannerConnection.scanFile(applicationModule.android.context, [path], null, callback);