本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}