0

I'm running a WebView on Android app and now I have discovered that I have a problem when I added a new feature to my website which is to upload a profile image and on my Android app this doesn't work. I'm looking for a solution with good compatibility for multiple Android versions like android 10, 9 and below for example.

Anyone with the same problem has solved it? Please help me and tell how can I solve this problem.

package com.example.project;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private WebView myWebView;

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

        WebView myWebView = (WebView) findViewById(R.id.webview);

        WebSettings settings = myWebView.getSettings();

        settings.setJavaScriptEnabled(true);
        settings.setAllowFileAccessFromFileURLs(true);
        settings.setAllowUniversalAccessFromFileURLs(true);
        settings.setDomStorageEnabled(true);
        settings.setMediaPlaybackRequiresUserGesture(false);

        myWebView.setWebViewClient(new WebViewClient());

        myWebView.loadUrl("localhost/project");
    }

    @Override
    public void onBackPressed() {
        if (myWebView.canGoBack()){
            myWebView.goBack();
        }else{
            super.onBackPressed();
        }
    }
}
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
David
  • 59
  • 2
  • 8
  • Possible duplicate of [File Upload in WebView](https://stackoverflow.com/questions/5907369/file-upload-in-webview) – HB. Sep 26 '19 at 17:29
  • yes i saw that ticket, but it has 8 years, you think is working currently? – David Sep 26 '19 at 17:35
  • There is a lot of answer, the latest one was answered April of this year. – HB. Sep 26 '19 at 17:38
  • i'm trying to look for a solution for example for android 10, 9 and below. but thx for your help – David Sep 26 '19 at 17:49

0 Answers0