WebView goBack - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WebView goBack method.

This code example shows how to use the following methods:canGoBack, goBack
  } 
 
  @Override 
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (webView.canGoBack()) {
        webView.goBack();
        return true; 
      } 
    } 
    return super.onKeyDown(keyCode, event);
  } 
 
  private final class HelpClient extends WebViewClient {
    @Override 
    public void onPageFinished(WebView view, String url) {
      setTitle(view.getTitle());
      backButton.setEnabled(view.canGoBack());
    } 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
  } 
 
  @Override 
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (webView.canGoBack()) {
        webView.goBack();
        return true; 
      } 
    } 
    return super.onKeyDown(keyCode, event);
  } 
 
  private final class HelpClient extends WebViewClient {
    @Override 
    public void onPageFinished(WebView view, String url) {
      setTitle(view.getTitle());
      backButton.setEnabled(view.canGoBack());
    } 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
    mWebView.loadUrl("http://developer.android.com");
  } 
 
  @Override 
  public void onBackPressed() { 
    if (mWebView.canGoBack())
      mWebView.goBack();
    else 
      super.onBackPressed(); 
  } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
 
    //Handle the back key 
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (mWebView != null) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
                mWebView.goBack();
                return true; 
            } 
        } 
        return super.onKeyDown(keyCode, event);
    } 
 
    @Override 
    public void onClick(View v) {
        String tag = (String)v.getTag();
        if ("refresh".equals(tag)) {
            mWebView.reload();
        } 
        else if ("back".equals(tag)) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, canGoForward, goBack, goForward, reload
 
	} 
 
	@Override 
	public void onClick(View v) {
		if (v.getId() == mBackButton.getId() && mWebView.canGoBack()) { // 上一頁
			mWebView.goBack();
		} else if (v.getId() == mForwardButton.getId() && mWebView.canGoForward()) { // 下一頁
			mWebView.goForward();
		} else if (v.getId() == mRefreshButton.getId()) { // 重新整理
			mWebView.reload();
		} 
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, canGoForward, goBack, goForward
        } 
 
        @Override 
        public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
            int keyCode = event.getKeyCode();
            if ((keyCode == KeyEvent.KEYCODE_DPAD_LEFT) && view.canGoBack()) {
                view.goBack();
                return true; 
            } else if ((keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) && view.canGoForward()) {
                view.goForward();
                return true; 
            } 
            return false; 
        } 
 
        @Override 
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
                // ジェスチャーの名前をトーストでチン 
                Toast.makeText(this, prediction.name,
                               Toast.LENGTH_SHORT).show();
                if ("back".equals(prediction.name)) {
                    // 戻れるか判定して 
                    if(mWebView.canGoBack()) {
                        // 戻る! 
                        mWebView.goBack();
                    } 
                } 
            } 
        } 
        // ジェスチャー受け付けを無効にする 
        overlay.setEnabled(false);
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, getUrl, goBack, loadUrl
 
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if ((keyCode == KeyEvent.KEYCODE_BACK) && isStartPage()) {
			// on quit application.. 
			// getMetrics here... 
			System.out.println("com.manuelmaly.mockingdroid.monitor: " + this.monitor.getMetrics(webview.getUrl()));
 
			if (this.lastBackPressTime < System.currentTimeMillis() - 2000) {
				backToast = Toast.makeText(this, "Press back again to end this session!", Toast.LENGTH_SHORT);
				backToast.show();
				this.lastBackPressTime = System.currentTimeMillis();
				return true; 
			} else { 
				if (backToast != null)
					backToast.cancel();
				return super.onKeyDown(keyCode, event); // let app handle back button (activity end)
			} 
		} else if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
			if (backButtonGloballyAllowed && currentPageBackButtonAllowed) {
				if (currentPageBackButtonURL != null) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
	} 
 
	// Handle Android physical back button. 
	@Override 
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
			webView.goBack();
			return true; 
		} 
		return super.onKeyDown(keyCode, event);
	} 
 
	@Override 
	public void onSaveInstanceState(Bundle savedInstanceState) {
		super.onSaveInstanceState(savedInstanceState);
		savedInstanceState.putInt("currentPage", currentPage);
	} 
 
	@Override 
	public void onRestoreInstanceState(Bundle savedInstanceState) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
			return true; 
		} 
	} 
	@Override 
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	    if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
	        webview.goBack();
	        return true; 
	    } 
	    return super.onKeyDown(keyCode, event);
	} 
			 
} 
	 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related WebView goBack Questions & Answers:

Other WebView goBack Examples

29:		public boolean onKeyDown(int keyCode, KeyEvent event) {
30:		    if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
31:		    	webview.goBack();
32:		        return true;
33:		    }

Read More

goBack Method Overview
Goes back in the history of this WebView.
See Code Examples for other Android WebView Methods: