android webview客户端活动指标

前端之家收集整理的这篇文章主要介绍了android webview客户端活动指标前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Webview中获得了显示活动指标的代码.我检查了多个参考,但仍然无法使其正常工作.你能帮我下面调试我的代码吗?

活动指标不在下面的代码

  1. protected void onCreate(Bundle savedInstanceState) {
  2. // TODO Auto-generated method stub
  3. super.onCreate(savedInstanceState);
  4. this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
  5. final BaseActivity MyActivity = ReviewWebActivity.this;
  6. setContentView(R.layout.review_web);
  7. getWindow().setFeatureInt(Window.FEATURE_PROGRESS,Window.PROGRESS_VISIBILITY_ON);
  8.  
  9.  
  10. ScannedProduct product = getReviewUrl();
  11. reviewUrl = product.getReviewLink();
  12.  
  13. if (reviewUrl == null) {
  14. String err = product.getErrorCode();
  15. if(err.equals("")) err ="No Data Available for this product";
  16. Toast.makeText(getApplicationContext(),"No Data Available for this product",1).show();
  17. return;
  18. }
  19.  
  20. webReview = (WebView) findViewById(R.id.webReview);
  21. webReview.setWebChromeClient(new WebChromeClient() {
  22. public void onProgressChanged(WebView view,int progress) {
  23. // Make the bar disappear after URL is loaded,and changes
  24. // string to Loading...
  25. MyActivity.setTitle("Loading...");
  26. MyActivity.setProgress(progress * 1000); // tried with 100 also
  27.  
  28.  
  29. }
  30. });
  31. webReview.setWebViewClient(new ReviewWebClient());
  32. webReview.getSettings().setJavaScriptEnabled(true);
  33.  
  34. webReview.loadUrl(reviewUrl);
  35. }

解决方法

  1. import android.app.Activity;
  2. import android.app.ProgressDialog;
  3. import android.os.Bundle;
  4. import android.webkit.WebView;
  5. import android.webkit.WebViewClient;
  6.  
  7. public class SandbarinFacebook extends Activity {
  8. WebView mWebView;
  9.  
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.main);
  13.  
  14. final ProgressDialog pd = ProgressDialog.show(this,"","Loading...",true);
  15.  
  16. mWebView = (WebView) findViewById(R.id.webkitWebView1);
  17. mWebView.getSettings().setJavaScriptEnabled(true);
  18. mWebView.getSettings().setSupportZoom(true);
  19. mWebView.getSettings().setBuiltInZoomControls(true);
  20. mWebView.setWebViewClient(new WebViewClient() {
  21. @Override
  22. public void onPageFinished(WebView view,String url) {
  23. if(pd!=null && pd.isShowing())
  24. {
  25. pd.dismiss();
  26. }
  27. }
  28. });
  29. mWebView.loadUrl("http://www.yahoo.co.in");
  30. setTitle("Yahoo!");
  31. }
  32. }

猜你在找的Android相关文章