1

I already looked the 'webview fileup load' post from stack overflow but mine does not show any pop up. please look at it more carefully

Let say I have following html code to access the android gallery.

 <form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="uploadfile">&nbsp;&nbsp;
<input type="submit" value="Press to Upload..."> to upload the file!
</form>

after I implemented the onCreate. and when I click the button for the file upload. it does not open anything. but it only showed

D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1

this is an error message.
and following is the code for onCreate

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        web  = (WebView)findViewById(R.id.webView);

        ln1=(LinearLayout) findViewById(R.id.ln1);

        WebSettings settings =  web.getSettings();
        settings.setJavaScriptEnabled(true);

        web.loadUrl("http://github.tkddnjsdja.tk/");
        web.setWebViewClient(new myWebClient());

        web.setWebChromeClient(new WebChromeClient(){

            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                MainActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);

            }



        });

        //setContentView(web);

    }

when I click the button it only shows
and nothing changed. any one help?

i gaved following permissions

 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
    <uses-permission  android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
    <uses-permission android:name ="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.hardware.camera"></uses-permission>
kong kim
  • 29
  • 1
  • 4
  • Possible duplicate of [File Upload in WebView](https://stackoverflow.com/questions/5907369/file-upload-in-webview) – Rashid Jul 10 '17 at 08:49
  • yes i looked at the following link but my code does not open the gallery. this code probably from following link you provide – kong kim Jul 10 '17 at 08:50
  • 1
    web.loadUrl("http://github.tkddnjsdja.tk/"); what's this? – curiousMind Jul 10 '17 at 08:55
  • did you check if it has permission to open the gallery? – Rashid Jul 10 '17 at 09:00
  • check this link. It may be useful to you https://stackoverflow.com/questions/44042720/choose-image-from-gallery-and-camera-through-web-view-upload-is-not-working-in-a – Dhanumjay Jul 10 '17 at 09:00
  • check in your settings under application permission if it enables the following permission – Rashid Jul 10 '17 at 09:02
  • I put the list of permissions at the end of my discussion – kong kim Jul 10 '17 at 09:02
  • @kongkim yes, there is a possibility that you add your permission but it is still disabled. this feature was implement on Android Marshmallow and up. you can implement a permission checking as discuss here https://stackoverflow.com/a/10168114/5870896 – Rashid Jul 10 '17 at 09:07
  • i need more help with permission – kong kim Jul 10 '17 at 12:01
  • @Secret Coder can you help me more about permission? – kong kim Jul 10 '17 at 12:57
  • the link i gave you yesterday contains the code for asking permission https://stackoverflow.com/a/10168114/5870896 – Rashid Jul 11 '17 at 01:26

0 Answers0