0

im working on Android 4.0. i have a WebView where i want to capture its screen. i Override the WebViewClient onPageFinished as folow:

@Override
public void onPageFinished(WebView view, String url) {
                Picture picture = view.capturePicture();
Toast.makeText(finplan.this, "picture height "+picture.getHeight()+ " url "+url, Toast.LENGTH_LONG).show();

in another procedure i called the loadUrl:

mywebview.loadUrl("http://www.google.com"); 
// this one works fine and picture.getHeight() is > 0

mywebview.loadUrl("file:///android_asset/test.html"); 
// this one works, but the picture.getHeight() retrieved in onPageFinished is always 0

test.html is a any simple html file, i notice later that any loadUrl with "http//" works fine but dont works on 'file://'. Any help in this ???

Arun C
  • 9,035
  • 2
  • 28
  • 42

1 Answers1

0

paste your .html file in assets folder of your project folder. and create an xml file in layout folder with the fol code: my.xml:

   <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/webview"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
          />

add fol code in activity

setContentView(R.layout.my);
WebView mWebView = null;
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/new.html"); //new.html is html file name.
Make it Simple
  • 1,832
  • 5
  • 32
  • 57