wifisher commented on issue #611:
URL: 
https://github.com/apache/cordova-plugin-camera/issues/611#issuecomment-700273405


   Not sure if this is related or not, but v5.0.0 of the plugin fails for me as 
well with saveToPhotoAlbum set true. For me, it is also failing on my Android 8 
test device with the following stack trace:
   
   ```
    java.io.FileNotFoundException: 
content:/com.fi.pmp.cordova.plugin.camera.provider/cache_files/.Pic.jpg (No 
such file or directory)
       at java.io.FileInputStream.open0(Native Method)
       at java.io.FileInputStream.open(FileInputStream.java:200)
       at java.io.FileInputStream.<init>(FileInputStream.java:150)
       at java.io.FileInputStream.<init>(FileInputStream.java:103)
       at 
org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:906)
       at 
org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:503)
       at 
org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:808)
       at 
org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:159)
       at 
org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:361)
       at android.app.Activity.dispatchActivityResult(Activity.java:7599)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:4487)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:4534)
       at android.app.ActivityThread.-wrap20(Unknown Source:0)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Native Method)
       at 
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
   ```
   
   It appears that the source URI has a content: scheme instead of a file: 
scheme that writeUncompressedImage() expects.
   
   I was able to get it working by changing line 903 of CameraLauncher.java 
from:
   
   `FileInputStream fis = new 
FileInputStream(FileHelper.stripFileProtocol(src.toString()));`
   
   to
   
   `InputStream fis = 
this.cordova.getActivity().getContentResolver().openInputStream(src);`
   
   openInputStream() is documented to accept both file: and content: schemes, 
so this change should handle both cases.
   
   With this change, saveToPhotoAlbum works again on this Android 8 device. I 
haven't had a chance to test on any other devices yet.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to