mgks / Android-SmartWebView

A simple use webview integrated w/ native features to help create most advanced hybrid applications.
https://mgks.dev/smart-webview
MIT License
571 stars 278 forks source link

The camera cannot be used Find the error code #181

Open lip5201 opened 4 years ago

lip5201 commented 4 years ago
      It has been tested that there is a problem with the broken code here. Can you fix it?

After deleting this code, I can call up the camera, but I can’t upload pictures after taking pictures.

                                    paramCheck:
                        for (String acceptTypes : fileChooserParams.getAcceptTypes()) {
                            // Although it's an array, it still seems to be the whole value. 
                            // Split it out into chunks so that we can detect multiple values.
                            String[] splitTypes = acceptTypes.split(", ?+");
                            for (String acceptType : splitTypes) {
                                switch (acceptType) {
                                    case "*/*":
                                        includePhoto = true;
                                        includeVideo = true;
                                        break paramCheck;
                                    case "image/*":
                                        includePhoto = true;
                                        break;
                                    case "video/*":
                                        includeVideo = true;
                                        break;
                                }
                            }
                        }
mgks commented 4 years ago

It's not about the code that's broken, this particular problem is happening across different devices no matter the SDK or Android variant. Instead, this is the only snipped I got to work across majority of devices.

But we're trying dude. This bug is messy.

lip5201 commented 4 years ago

The project is great!

The problem has been solved, there is no problem calling the camera code! The great reason is that type="file" gets the empty type, which affects the code judgment

I added the default value judgment at the end

                                       default:
                                       includePhoto = true;                                 
                                       break;   

switch (acceptType) { case "/": includePhoto = true; includeVideo = true; break paramCheck; case "image/": includePhoto = true; break; case "video/": includeVideo = true; break; default: includePhoto = true;
break;
} }