2012-04-23 1 views
0

내 안드로이드 애플 리케이션에서 Webview를 표시해야합니다.내 안드로이드 애플 리케이션에서 웹보기를 표시하는 중 오류가 발생했습니다.

"This page contains the following errors: 

error on line xxx at column xxx: Entity 'abc' is not defined 

Below is the rendering of the page upto the first error" 

사이트 내 모바일 브라우저에서 잘 작동하고 또한 내 바탕 화면 : 문제는 내가 보여 주려하고있는 웹 페이지가 오류를 준다이다. 또한, 나는 다른 웹 사이트

으로이 오류가없는 것은 어쨌든 나는이 오류가 피할 수입니다. 친절하게 도와주세요.

는 자바 코드 :

public class Zero extends Activity { 

    WebView wv; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     getWindow().requestFeature(Window.FEATURE_PROGRESS); 
     setContentView(R.layout.zero); 



     wv=(WebView) findViewById(R.id.web); 
     wv.getSettings().setJavaScriptEnabled(true); 
     //wv.loadUrl("http://customercare.indianrailways.gov.in/criscm/common/complaint_registration.seam"); 
     wv.loadUrl("http://ndtv.com"); 
     wv.setWebViewClient(new HelloWebViewClient()); 

     final Activity activity = this; 

     wv.setWebChromeClient(new WebChromeClient(){ 

      public void onProgressChanged(WebView view, int progress) { 
        activity.setTitle("Loading..."); 
        activity.setProgress(progress * 100); 
         if(progress == 100) 
          activity.setTitle("Easy Complaint Indian Railways"); 
        } 
    }); 

    } 

    private class HelloWebViewClient extends WebViewClient { 
     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      view.loadUrl(url); 
      return true; 
     } 
    } 

    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
     if ((keyCode == KeyEvent.KEYCODE_BACK) && wv.canGoBack()) { 
      wv.goBack(); 
      return true; 
     } 
     return super.onKeyDown(keyCode, event); 
    } 
} 

레이아웃 XML 파일 :

<?xml version="1.0" encoding="utf-8"?> 
<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/web"> 
</WebView> 
+0

왜 2 대의 클라이언트를 정의했으며이 2 대의 클라이언트를 설정하고 있습니까? –

+0

자습서 http://developer.android.com/resources/tutorials/views/hello-webview.html을 따르고있었습니다. 솔직히 말해서 튜토리얼의 일부분을 이해하지 못했지만 어쨌든 사용했습니다. 제 코드에 뭐가 잘못 됐는지 알려주세요. 2 클라이언트 또는 다른 것을 사용하여 – ambit

+0

문제가 해결 되었습니까? –

답변

0

를 사용하여 아래의 활동이 URL :::

public class WebViewsScreenActivity extends Activity { 

private WebView mwebview; 
private WebViewsScreenActivity _activity; 
ProgressDialog _dilog; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    getWindow().requestFeature(Window.FEATURE_PROGRESS); 
    setContentView(R.layout.webview); 
    _activity = this; 
    mwebview=(WebView)findViewById(R.id.webview); 
       mwebview.getSettings().setJavaScriptEnabled(true); 
       mwebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); 

    if(checkInternetConnection(_activity)){ 
    if(savedInstanceState==null)  
          mwebview.loadUrl(webUrl); 
    else 
    mwebview.restoreState(savedInstanceState); 
    } 
    else{ 
    //showAlert "Unable to Connect Server" 
    } 
     mwebview.setWebChromeClient(new WebChromeClient() { 

      @Override 
    public void onProgressChanged(WebView view, int progress) { 
      if(mwebview.getVisibility()==View.VISIBLE) 
      { 
      WebViewsScreenActivity .this.setProgress(progress * 100); 

      } 
      } 
      }); 
     mwebview.setWebViewClient(new HelloWebViewClient()); 
} 

@Override 
public boolean onKeyUp(int keyCode, KeyEvent event) { 
    // TODO Auto-generated method stub 
    if(keyCode == KeyEvent.KEYCODE_BACK) 
    { 
    mwebview.goBack(); 
    return true; 
    } 
    else 
    return super.onKeyUp(keyCode, event); 
} 


//To check whether network connection is available on device or not 
private boolean checkInternetConnection(Activity _activity) { 
    ConnectivityManager conMgr = (ConnectivityManager) _activity.getSystemService(Context.CONNECTIVITY_SERVICE); 
    if (conMgr.getActiveNetworkInfo() != null 
    && conMgr.getActiveNetworkInfo().isAvailable() 
    && conMgr.getActiveNetworkInfo().isConnected()) 
    return true; 
    else 
    return false; 
}//checkInternetConnection() 



    //HelloWebViewClient class for webview 
    private class HelloWebViewClient extends WebViewClient { 

    @Override 
    public void onPageStarted(WebView view, String url, Bitmap favicon) { 
     // TODO Auto-generated method stub 
     super.onPageStarted(view, url, favicon); 
    } 
    @Override 
    public void onReceivedError(WebView view, int errorCode, 
     String description, String failingUrl) { 
     // TODO Auto-generated method stub 
     super.onReceivedError(view, errorCode, description, failingUrl); 

    } 
    @Override 
    public void onPageFinished(WebView view, String url) { 
     // TODO Auto-generated method stub 
     super.onPageFinished(view, url); 
    } 
} //HelloWebViewClient-class 
}//AccountsScreenActivity-class 

주를로드하기 :: manifeast 파일에 필요한 권한을 추가하는 것을 잊지 마십시오.

+0

코드를 시도했지만 여전히 같은 오류가 발생합니다. 웹 사이트에 문제가 있다고 생각합니다. 그러나 놀랍게도이 오류는 브라우저를 사용하여 사이트를 열 때 발생하지 않습니다. 어쨌든, 고맙다. 다른 것을 제안 할 수 있다면 알려 주시기 바랍니다. – ambit

+0

URL은 무엇입니까? –

+0

다음 URL입니다. http://customercare.indianrailways.gov.in/criscm/common/complaint_registration.seam – ambit

관련 문제