當前位置: 首頁>>代碼示例>>Java>>正文


Java WebView.restoreState方法代碼示例

本文整理匯總了Java中android.webkit.WebView.restoreState方法的典型用法代碼示例。如果您正苦於以下問題:Java WebView.restoreState方法的具體用法?Java WebView.restoreState怎麽用?Java WebView.restoreState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.restoreState方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import android.webkit.WebView; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    destroyWebView();

    mWebView = new WebView(getActivity());
    mWebView.setWebViewClient(mWebViewClient);
    mWebView.getSettings().setJavaScriptEnabled(true);

    if (savedInstanceState == null) {
        mWebView.loadUrl(mUrl);
    } else {
        mWebView.restoreState(savedInstanceState);
    }

    mIsWebViewAvailable = true;
    return mWebView;
}
 
開發者ID:fivef,項目名稱:add_to_evernote_note,代碼行數:19,代碼來源:EvernoteOAuthActivity.java

示例2: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.help);

  webView = (WebView) findViewById(R.id.help_contents);

  if (icicle == null) {
    webView.loadUrl(BASE_URL + "index.html");
  } else {
    webView.restoreState(icicle);
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:14,代碼來源:HelpActivity.java

示例3: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.help);

  webView = (WebView)findViewById(R.id.help_contents);
  webView.setWebViewClient(new HelpClient(this));

  Intent intent = getIntent();
  String page = intent.getStringExtra(REQUESTED_PAGE_KEY);

  // Show an OK button.
  View doneButton = findViewById(R.id.done_button);
  doneButton.setOnClickListener(doneListener);

  if (page.equals(DEFAULT_PAGE)) {
    doneButton.setVisibility(View.VISIBLE);
  } else {
    doneButton.setVisibility(View.GONE);
  }

  // Froyo has a bug with calling onCreate() twice in a row, which causes the What's New page
  // that's auto-loaded on first run to appear blank. As a workaround we only call restoreState()
  // if a valid URL was loaded at the time the previous activity was torn down.
  if (icicle != null && icicle.getBoolean(WEBVIEW_STATE_PRESENT, false)) {
    webView.restoreState(icicle);
  } else if (intent != null && page != null && page.length() > 0) {
    webView.loadUrl(BASE_URL + page);
  } else {
    webView.loadUrl(BASE_URL + DEFAULT_PAGE);
  }
}
 
開發者ID:mercuriete,項目名稱:android-mrz-reader,代碼行數:33,代碼來源:HelpActivity.java

示例4: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Context of this activity
    mContext = this;

    // Get main WebView component
    mWebView = (WebView) findViewById(R.id.wv_main);

    // Get ProgressBar component
    mProgress = (ProgressBar) findViewById(R.id.pb_loading);

    // Attach clients to mWebView to measure progress and errors
    mWebView.setWebViewClient(new WebClient());
    mWebView.setWebChromeClient(new ChromeClient());

    // Get settings for mWebView
    WebSettings settings = mWebView.getSettings();
    // The two lines below are to enable interpreting <meta viewport> tag.
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    // Enable JavaScript
    settings.setJavaScriptEnabled(true);

    // Load AdBlocker
    mAdBlocker = new AdBlocker(this);
    mAdBlocker.execute();

    // Load MangaFox
    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        mWebView.loadUrl(MANGAFOX_URL);
    }
}
 
開發者ID:dipu-bd,項目名稱:mangafox,代碼行數:38,代碼來源:MainActivity.java

示例5: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_web);
    name = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_NAME);
    url = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_URL);
    color = getIntent().getExtras().getInt(Common.WEBVIEW_EXTRA_COLOR);
    needsLogin = getIntent().getExtras().getBoolean(Common.WEBVIEW_EXTRA_NLOGIN);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(color);
        getWindow().setStatusBarColor(color);
    }
    app = (App) getApplication();

    TextView title = (TextView) findViewById(R.id.toolbar_title);
    title.setText(name);

    progress = (ProgressBar) findViewById(R.id.web_progressBar);
    webView = (WebView) findViewById(R.id.webView);

    if (savedInstanceState != null) {
        progress.setVisibility(View.INVISIBLE);
        webView.setVisibility(View.VISIBLE);
        webView.restoreState(savedInstanceState);
    }
    else {
        progress.setVisibility(View.VISIBLE);
        webView.setWebViewClient(new WebViewClient());
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUserAgentString("IEMobile");
        startControllers();
    }

}
 
開發者ID:Onelio,項目名稱:ConnectU,代碼行數:41,代碼來源:WebActivity.java

示例6: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_web);
    name = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_NAME);
    url = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_URL);
    color = getIntent().getExtras().getInt(Common.WEBVIEW_EXTRA_COLOR);
    needsLogin = getIntent().getExtras().getBoolean(Common.WEBVIEW_EXTRA_NLOGIN);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(color);
        getWindow().setStatusBarColor(color);
    }
    app = (App) getApplication();
    if (app.account == null && !app.loadUser()) //If account is null and cannot create user
        super.onDestroy();

    TextView title = (TextView) findViewById(R.id.toolbar_title);
    title.setText(name);

    progress = (ProgressBar) findViewById(R.id.web_progressBar);
    webView = (WebView) findViewById(R.id.webView);

    if (savedInstanceState != null) {
        progress.setVisibility(View.INVISIBLE);
        webView.setVisibility(View.VISIBLE);
        webView.restoreState(savedInstanceState);
    }
    else {
        progress.setVisibility(View.VISIBLE);
        webView.setWebViewClient(new WebViewClient());
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUserAgentString("IEMobile");
        startControllers();
    }
}
 
開發者ID:Onelio,項目名稱:ConnectU,代碼行數:42,代碼來源:WebmailActivity.java


注:本文中的android.webkit.WebView.restoreState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。