简体   繁体   English

使用webchromeclient获取要加载的webview

[英]Getting a webview to load with webchromeclient

I cant see me get this web view to open up with the new code below. 我看不到我可以通过以下新代码打开此网络视图。 I had it working with the commented out code. 我有它与注释掉的代码一起工作。 I need to get the new code to load the web view. 我需要获取新代码以加载Web视图。 Im using this sample code. 我正在使用此示例代码。 How can i fix the issues of it not opening up the page? 我该如何解决无法打开页面的问题? The Sample code 样例代码

@Override   
 protected void onActivityResult(int requestCode, int resultCode,    
                                    Intent intent) {    
  if(requestCode==FILECHOOSER_RESULTCODE)    
  {    
   if (null == mUploadMessage) return;    
           Uri result = intent == null || resultCode != RESULT_OK ? null   
                   : intent.getData();    
           mUploadMessage.onReceiveValue(result);    
           mUploadMessage = null;    

}    
}    

@Override
public boolean onOptionsItemSelected(MenuItem item) {    
    // Handle item selection    
    switch (item.getItemId()) {        
    case R.id.register:            
        //mWebView2 = (WebView) findViewById(R.id.webview);    
       // mWebView2.getSettings().setJavaScriptEnabled(true);    
       // mWebView2.loadUrl("http://www.Mysite.com/AndroidAddMember.aspx");
        //mWebView2.setWebViewClient(new HelloWebViewClient());   

        wv = new WebView(this);  
        wv.setWebViewClient(new WebViewClient());   
        wv.getSettings().setJavaScriptEnabled(true); 

        wv.loadUrl("http://www.Mysite.com/AndroidAddMember.aspx"); 

          wv.setWebViewClient(new WebViewClient());    
          wv.setWebChromeClient(new WebChromeClient()    
          {    
                 //The undocumented magic method override    
                 //Eclipse will swear at you if you try to put @Override here    

              public void openFileChooser(ValueCallback<Uri> uploadMsg) {    

                  mUploadMessage = uploadMsg;    
                  Intent i = new Intent(Intent.ACTION_GET_CONTENT);    
                  i.addCategory(Intent.CATEGORY_OPENABLE);    
                  i.setType("image/*");    
                  BangMeorNot.this.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);    

                 }    
        });    
            setContentView(wv);    

        return true;        

Maybe because you are initializing the same webview twice and during the second time, you are not calling loadUrl() method on it. 可能是因为您要两次初始化同一Webview,并且在第二次初始化时,您没有在其上调用loadUrl()方法。

Try setting the url after the second initialization also. 也尝试在第二次初始化后设置网址。 The problem is that you are setting the content view to the webview, but the webview has no url to load. 问题是您正在将内容视图设置为Web视图,但是Web视图没有要加载的URL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在WebView的webChromeClient中不会关闭ProgressDialog - ProgressDialog not getting dismissed in webChromeClient in WebView WebChromeClient的onShowFileChooser无法与android studio中的webview一起使用 - WebChromeClient's onShowFileChooser not working with webview in android studio Android WebView WebChromeClient:onProgressChanged() 中的进度值不准确 - Android WebView WebChromeClient : inaccurate progress value in onProgressChanged() WebView + WebChromeClient方法onCreateWindow没有调用target =“_ blank” - WebView + WebChromeClient method onCreateWindow not called for target=“_blank” 从未触发Android WebChromeClient WebView onGeolocationPermissionsShowPrompt - Android WebChromeClient WebView onGeolocationPermissionsShowPrompt never fired Android WebView WebChromeClient 示例应用程序问题 - Android WebView WebChromeClient example app issue Cordova WebView比Android WebChromeClient慢 - Cordova WebView slower than Android WebChromeClient Android webview:未定义类型new WebChromeClient(){}的方法setProgress(int) - Android webview: The method setProgress(int) is undefined for the type new WebChromeClient(){} 无法使用WebChromeClient在WebView Android 4.4.2中打开文件选择器 - can't open file chooser in WebView Android 4.4.2 using WebChromeClient Android webview SKIPS javascript甚至包含setJavascriptEnabled(true)和WebChromeClient - Android webview SKIPS javascript even with setJavascriptEnabled(true) and WebChromeClient
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM