Phonegap video capture crashes

后端 未结 2 980
旧巷少年郎
旧巷少年郎 2021-01-01 04:53

I\'ve made a relatively simple phonegap app, with the ability to capture images and videos and upload them to a server.

Images work fine, however when I call to capt

2条回答
  •  青春惊慌失措
    2021-01-01 05:43

    A workaround for this issue is to edit [yourApp]\plugins\org.apache.cordova.media-capture\src\android\Capture.java

    Starting at line 377, change this code

    private JSONObject createMediaFile(Uri data) {
        File fp = webView.getResourceApi().mapUriToFile(data);
        JSONObject obj = new JSONObject();
    

    to the following code

    private JSONObject createMediaFile(Uri data) {
        // is thread checking enabled?
        boolean thC = webView.getResourceApi().isThreadCheckingEnabled();       
        // set thread checking to disabled (this works around mapUriToFile failing with IllegalStateException: Do not perform IO operations on the UI thread.
        webView.getResourceApi().setThreadCheckingEnabled(false);       
        File fp = webView.getResourceApi().mapUriToFile(data);
        // set thread checking back to whatever it was before the call above.
        webView.getResourceApi().setThreadCheckingEnabled(thC);
        JSONObject obj = new JSONObject();
    

    This worked for us, hopefully it will be fixed properly soon.

提交回复
热议问题