Android:在2.X.X或更低版本的webview中单击时没有弹出窗口

Android:在2.X.X或更低版本的webview中单击时没有弹出窗口,android,webview,popup,Android,Webview,Popup,我一直在努力从一个网站创建一个应用程序。在运行3.x或更高版本的设备上,一切似乎都正常工作,但在运行2.x.x或更低版本的设备上,我遇到了一个问题。问题归结为:在网站上,当你点击一个按钮附加一个文件时,会打开一个弹出窗口来选择该文件。只有在应用程序中,它才会清除屏幕,并且只显示白色背景 所以我想知道我需要做什么才能让弹出窗口在安卓2.x.x上工作 是webView.getSettings行,还是我可能需要在setWebViewClient函数中的shouldOverrideUrlLoading函

我一直在努力从一个网站创建一个应用程序。在运行3.x或更高版本的设备上,一切似乎都正常工作,但在运行2.x.x或更低版本的设备上,我遇到了一个问题。问题归结为:在网站上,当你点击一个按钮附加一个文件时,会打开一个弹出窗口来选择该文件。只有在应用程序中,它才会清除屏幕,并且只显示白色背景

所以我想知道我需要做什么才能让弹出窗口在安卓2.x.x上工作

是webView.getSettings行,还是我可能需要在setWebViewClient函数中的shouldOverrideUrlLoading函数中添加一些内容

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<Uri> 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<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }                   

        @SuppressWarnings("unused")
        public void openFileChooser(ValueCallback<Uri> 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");
}

问题的解决方案是将shouldOverrideUrlLoading更改为以下内容:

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {
            return false;
        }
    });

你真的应该在你的答案中添加更多的细节,比如适当的代码,当前结果的一些图像,以及你想要实现的目标等等。所以我找到了与我的问题相关的问题。这与他应该超越阅读有关。我最后要做的就是剪切view.loadUrlurl;换行,然后将返回值更改为false。