1

I'm trying to create an Android app for my web system. This is my first try at Android Studio. I followed a few tutorials and made up something.

So when I open the app it opens my web system within the app.

There is a section that uploads images, but when I click it, it won't open and ask for a gallery or camera.

I would like to know how to do it.

I'm using Android Studio for this and these are the current codes.

MainActivity.java

public class MainActivity extends AppCompatActivity {
  WebView webView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    webView = findViewById(R.id.webview);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl("https://www.mysitenamegoeshear.com/");
    WebSettings websettings = webView.getSettings();
    websettings.setJavaScriptEnabled(true);
  }
  private class MyWebView extends WebViewClient {
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
      super.onPageStarted(view, url, favicon);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
      return super.shouldOverrideUrlLoading(view, request);

    }
  }

  @Override
  public void onBackPressed() {
    if (webView.isFocused() && webView.canGoBack()) {
      webView.goBack();
    } else {
      super.onBackPressed();
    }

  }

}

This is how it opens in the mobile browser. Here when It clicks to Choose File This pop-up appears. I want to do the same in my web view also.

enter image description here

nitinkumarp
  • 2,120
  • 1
  • 21
  • 30
Dev Beginner
  • 589
  • 1
  • 11

1 Answers1

0

This problem is not because of the Android application or the way you coded it. Since you are using a WebView, the html code of the website tells the WebView the proper dialog box to appear. You need to modify your html. See: HTML File Upload Doesn't Show Gallery on Android

asajadi84
  • 410
  • 5
  • 20