WebView canGoBack - 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 canGoBack 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());
    } 
 
Full Snippet Info
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());
    } 
 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: canGoBack, canGoForward
            view.loadUrl(url);
            return true; 
        } 
         
        public void handleHistoryChange() { 
            activity.setTitleButtonEnabled("back", mWebView.canGoBack());
            activity.setTitleButtonEnabled("forward", mWebView.canGoForward());
        } 
    }	 
 
    //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);
Full Snippet Info
7
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(); 
  } 
} 
Full Snippet Info
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)) {
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: canGoBack, getTitle
  } 
 
  private final class HelpClient extends WebViewClient {
    @Override 
    public void onPageFinished(WebView view, String url) {
      setTitle(view.getTitle());
      backButton.setEnabled(view.canGoBack());
    } 
 
    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      if (url.startsWith("file")) {
        // Keep local assets in this WebView. 
        return false; 
      } else { 
        // Open external URLs in Browser. 
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return true; 
      } 
    } 
Full Snippet Info
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, 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();
		} 
	} 
 
} 
Full Snippet Info
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);
        } 
 
Full Snippet Info
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);
    } 
} 
Full Snippet Info
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

Related WebView canGoBack Questions & Answers:

Other WebView canGoBack Examples

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

Read More

canGoBack Method Overview
Gets whether this WebView has a back history item.
See Code Examples for other Android WebView Methods: