Example usage for android.webkit WebView goForward

List of usage examples for android.webkit WebView goForward

Introduction

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

Prototype

public void goForward() 

Source Link

Document

Goes forward in the history of this WebView.

Usage

From source file:de.baumann.browser.helper.helper_webView.java

private static void webView_Touch(final Activity from, final WebView webView) {

    webView.setOnTouchListener(new class_OnSwipeTouchListener_webview(from) {
        public void onSwipeRight() {
            if (webView.canGoBack()) {
                webView.goBack();// w  ww  .  j  a v a2  s  . co m
            } else {
                Snackbar.make(webView, R.string.toast_back, Snackbar.LENGTH_SHORT).show();
            }
        }

        public void onSwipeLeft() {
            if (webView.canGoForward()) {
                webView.goForward();
            } else {
                Snackbar.make(webView, R.string.toast_forward, Snackbar.LENGTH_SHORT).show();
            }
        }
    });
}

From source file:com.macleod2486.utnow.MainActivity.java

public void forward(View view) {
    WebView utdirect = (WebView) findViewById(R.id.webView);
    if (utdirect.canGoForward())
        utdirect.goForward();
}

From source file:com.facebook.react.views.webview.ReactWebViewManager.java

@Override
public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray args) {
    switch (commandId) {
    case COMMAND_GO_BACK:
        root.goBack();/*  w  ww.ja v  a  2  s  .  c  o m*/
        break;
    case COMMAND_GO_FORWARD:
        root.goForward();
        break;
    case COMMAND_RELOAD:
        root.reload();
        break;
    case COMMAND_STOP_LOADING:
        root.stopLoading();
        break;
    case COMMAND_POST_MESSAGE:
        try {
            JSONObject eventInitDict = new JSONObject();
            eventInitDict.put("data", args.getString(0));
            root.loadUrl("javascript:(function () {" + "var event;" + "var data = " + eventInitDict.toString()
                    + ";" + "try {" + "event = new MessageEvent('message', data);" + "} catch (e) {"
                    + "event = document.createEvent('MessageEvent');"
                    + "event.initMessageEvent('message', true, true, data.data, data.origin, data.lastEventId, data.source);"
                    + "}" + "document.dispatchEvent(event);" + "})();");
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        break;
    case COMMAND_INJECT_JAVASCRIPT:
        root.loadUrl("javascript:" + args.getString(0));
        break;
    }
}

From source file:com.purchasingpower.inappbrowser.WebViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //setContentView(R.layout.activity_main);
    setContentView(getResources().getIdentifier("nativebrowserplugin", "layout", getPackageName()));
    if (!checkPermission()) {
        requestPermission();/* w w w.j av  a2s  . c  o m*/
    }
    Intent intent = getIntent();
    String url = intent.getExtras().getString("url");
    final WebView myWebView = (WebView) findViewById(
            getResources().getIdentifier("webview", "id", getPackageName()));
    myWebView.setWebViewClient(new MyWebViewClient());

    webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setAllowFileAccess(true);
    myWebView.setWebChromeClient(new PQChromeClient());
    //if SDK version is greater of 19 then activate hardware acceleration otherwise activate software acceleration
    if (Build.VERSION.SDK_INT >= 19) {
        myWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } else if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 19) {
        myWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    myWebView.loadUrl(url);

    back = (ImageView) findViewById(getResources().getIdentifier("back", "id", getPackageName()));
    back.setImageResource(getResources().getIdentifier("back_gray", "drawable", getPackageName()));
    forward = (ImageView) findViewById(getResources().getIdentifier("forward", "id", getPackageName()));
    forward.setImageResource(getResources().getIdentifier("forward_gray", "drawable", getPackageName()));
    done = (TextView) findViewById(getResources().getIdentifier("done", "id", getPackageName()));
    pbar = (ProgressBar) findViewById(getResources().getIdentifier("pbar", "id", getPackageName()));
    pbar.setVisibility(View.VISIBLE);
    back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (myWebView.canGoBack()) {
                myWebView.goBack();
            }
        }
    });
    forward.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (myWebView.canGoForward()) {
                myWebView.goForward();
            }
        }
    });
    done.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.v("Done", "Clicked");
            finish();
        }
    });
}