Example usage for android.webkit WebView saveWebArchive

List of usage examples for android.webkit WebView saveWebArchive

Introduction

In this page you can find the example usage for android.webkit WebView saveWebArchive.

Prototype

public void saveWebArchive(String filename) 

Source Link

Document

Saves the current view as a web archive.

Usage

From source file:com.pablog178.pdfcreator.android.PdfcreatorModule.java

private void generateWebArchiveFunction(HashMap args) {
    if (args.containsKey("fileName")) {
        Object fileName = args.get("fileName");
        if (fileName instanceof String) {
            this.fileName = (String) fileName;
            Log.i(PROXY_NAME, "fileName: " + this.fileName);
        }// ww  w.  ja va2  s.  c  o  m
    } else
        return;

    if (args.containsKey("view")) {
        Object viewObject = args.get("view");
        if (viewObject instanceof TiViewProxy) {
            TiViewProxy viewProxy = (TiViewProxy) viewObject;
            this.view = viewProxy.getOrCreateView();
            if (this.view == null) {
                Log.e(PROXY_NAME, "NO VIEW was created!!");
                return;
            }
            Log.i(PROXY_NAME, "view: " + this.view.toString());
        }
    } else
        return;

    try {
        WebView webView = (WebView) this.view.getNativeView();
        webView.saveWebArchive(
                TiFileFactory.getDataDirectory(true).getAbsolutePath() + File.separator + this.fileName);
        sendCompleteEvent();
    } catch (Exception exception) {
        Log.e(PROXY_NAME, "Error: " + exception.toString());
        sendErrorEvent(exception.toString());
    }
}