delight-im / Android-AdvancedWebView

Enhanced WebView component for Android that works as intended out of the box
MIT License
2.39k stars 574 forks source link

upload file failed #96

Closed lindow2009 closed 7 years ago

lindow2009 commented 7 years ago

android 6.0 Sumsang galaxy note4 upload file failed click input button open file choose window,but choose file not work and the button cann't click twice! how to fix this issue?

pengwei1024 commented 7 years ago

@lindow2009

public class AdvancedWebViewActivity extends Activity {

    AdvancedWebView advancedWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        advancedWebView = new AdvancedWebView(this);
        advancedWebView.getSettings().setJavaScriptEnabled(true);
        advancedWebView.loadUrl("http://baidu.com");
        setContentView(advancedWebView);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        advancedWebView.onActivityResult(requestCode, resultCode, data);
    }
}
ocram commented 7 years ago

@pengwei1024 Thanks for helping out!

@lindow2009 Did you try what @pengwei1024 suggested? This is documented in the README as well, but the suggested snippet is what's essential here.

chamnap commented 7 years ago

At least, it works for me! Thanks.

lindow2009 commented 7 years ago

yes,i just use sample code. and my web code is `

</div>
    var uploadImage = document.getElementById('uploadImage');
    var camera = uploadImage.getElementsByTagName('input')[0];
 camera.addEventListener('change',function(){

},!1); ` it doesn't work

ocram commented 7 years ago

@lindow2009 If you're really on Android 6.0 and if you used the code posted by @pengwei1024 then this should work fine, just as it seems to be working for @chamnap (Thanks!).

Your HTML code for the upload form has a restriction on the accept attribute, it uses the capture attribute and has some custom JavaScript code. Please try removing all that for testing purposes. You should really try a minimum working example in order to see where the bug is.