Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: No pop up on click in webview on 2.X.X or lower
    text
    copied!<p>I have been working to create an app from a website. Everything seems to work fine on devices running <em>3.x</em> and higher, but on devices with <em>2.x.x</em> or lower I have an issue. The issue boils down to this: on the website when you click on a button to attach a file it opens a pop up window to select the file. Only in the app it clears the screen and only gives a white background. </p> <p>So I'm wondering what I need to do to get the pop up window to work on Android <em>2.x.x</em>.</p> <p>Would it be a <code>webView.getSettings</code> line or would I possibly have to add something to the <code>shouldOverrideUrlLoading</code> function in the <code>setWebViewClient</code> function?</p> <pre><code>public class MainActivity extends Activity { final Activity activity = this; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_main); WebView webView = (WebView) findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.setWebChromeClient(new WebChromeClient() { public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); MainActivity.this.startActivityForResult( Intent.createChooser(i, "Image Browser"), FILECHOOSER_RESULTCODE); } @SuppressWarnings("unused") public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType) { openFileChooser(uploadMsg); } @SuppressWarnings("unused") public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType, String capture) { openFileChooser(uploadMsg); } public void onGeolocationPermissionsShowPrompt(String origin, android.webkit.GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } public boolean onConsoleMessage(ConsoleMessage cm){ Log.d("MyApplication", cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId() ); return true; } public void onProgressChanged(WebView view, int progress) { activity.setTitle("Loading..."); activity.setProgress(progress * 100); if(progress == 100) activity.setTitle(R.string.app_name); } }); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // Handle the error } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); webView.loadUrl("http://example.com"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload