0

I am new to Android.I created an android app like Website URL loaded into WebView. My app is working fine but problem is mywebsite contains file upload button which is not working from WebView. How to enable this button please help me

MainActivity.java

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = findViewById(R.id.webView);
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setDisplayZoomControls(false);
        webSettings.setBuiltInZoomControls(true);
        webView.setWebViewClient(new MainActivity.PQClient());
        webView.loadUrl("http://weburl");
    }

    public class PQClient extends WebViewClient {

        int color = 1;

        public PQClient() {
            this.color = color;
        }

        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            if (url.startsWith("mailto:")) {
                final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                view.getContext().startActivity(intent);
                return true;
            }

            if (url.startsWith("tel:")) {
                final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                view.getContext().startActivity(intent);
                return true;
            }

            if (url.startsWith("whatsapp:")) {
                final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                view.getContext().startActivity(intent);
                return true;
            }

            return false;
        }

        public void onPageStarted(WebView view, String url, Bitmap favicon) {

        }

        public void onPageFinished(WebView view, String url) {

            view.loadUrl("javascript:(function(){document.getElementById('android-app').style.display='none';})()");
            try {

            } catch (Exception exception) {
                exception.printStackTrace();
            }
        }
    }
}

This is my source code whenever clicking on upload button no response getting from WebView android app how to solve this.

rckrd
  • 3,124
  • 1
  • 13
  • 23

0 Answers0