Java Examples for android.webkit.WebChromeClient
The following java examples will help you to understand the usage of android.webkit.WebChromeClient. These source code samples are taken from different open source projects.
Example 1
Project: Android-AugmentedReality-master File: InstructionsActivity.java View source code |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.instructions_layout); mWebView = (WebView) findViewById(R.id.instructions_webview); WebSettings webSettings = mWebView.getSettings(); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); WebChromeClient client = new WebChromeClient(); mWebView.setWebChromeClient(client); mWebView.loadUrl("file:///android_asset/help/" + getResources().getString(R.string.help_file)); }
Example 2
Project: Android-Cookbook-Examples-master File: Main.java View source code |
/** Called when the activity is first created. */
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) this.findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webView.requestFocusFromTouch();
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
// Load the URL
webView.loadUrl("file:///android_asset/rgraphview.html");
}
Example 3
Project: m2e-master File: Main.java View source code |
/** Called when the activity is first created. */
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) this.findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webView.requestFocusFromTouch();
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
// Load the URL
webView.loadUrl("file:///android_asset/rgraphview.html");
}
Example 4
Project: pola-android-master File: ActivityWebView.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
if (getIntent() != null && getIntent().getExtras() != null && getIntent().getExtras().containsKey("url")) {
webView.loadUrl(getIntent().getExtras().getString("url"));
} else {
webView.loadUrl(Utils.URL_POLA_ABOUT);
}
webView.setWebChromeClient(new WebChromeClient());
}
Example 5
Project: Cafe-master File: WebElementRecorder.java View source code |
/** * use java reflect mechanism to get original WebChromeClient object * * @param webView * @return */ private WebChromeClient getOriginalWebChromeClient(final WebView webView) { WebChromeClient mWebChromeClient = null; try { if (Build.VERSION.SDK_INT > 14) { Object originalWebViewClassic = viewRecorder.getLocalLib().invoke(webView, "android.webkit.WebView", "getWebViewProvider", new Class[] {}, new Object[] {}); Object originalCallbackProxy = viewRecorder.getLocalLib().getField(originalWebViewClassic, null, "mCallbackProxy"); mWebChromeClient = (WebChromeClient) viewRecorder.getLocalLib().getField(originalCallbackProxy, null, "mWebChromeClient"); } else { mWebChromeClient = (WebChromeClient) viewRecorder.getLocalLib().invoke(webView, "android.webkit.WebView", "getWebChromeClient", new Class[] {}, new Object[] {}); } } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return mWebChromeClient; }
Example 6
Project: Android-PullToNextLayout-master File: WebViewFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
index = getArguments().getInt("index");
View v = inflater.inflate(R.layout.fragment_web_view, container, false);
webView = (WebView) v.findViewById(R.id.webView);
String[] urls = getResources().getStringArray(R.array.urls);
webView.loadUrl(urls[index]);
webView.setWebChromeClient(new WebChromeClient());
return v;
}
Example 7
Project: EdgeEffectOverride-master File: WebViewActivity.java View source code |
private void initWebView() {
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
WebSettings settings = mWebView.getSettings();
settings.setSavePassword(true);
settings.setSaveFormData(true);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setDomStorageEnabled(true);
settings.setSupportMultipleWindows(false);
mWebView.loadUrl("http://developer.android.com");
}
Example 8
Project: GaoRenZhiLu-master File: WebBrowserActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_browser);
setTitle("æ£åœ¨åŠ è½½...");
showLeftBackButton();
pb_load = (ProgressBar) findViewById(R.id.pb_load);
WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
pb_load.setVisibility(View.GONE);
super.onPageFinished(view, url);
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
setTitle(title);
}
});
webView.getSettings().setJavaScriptEnabled(true);
String url = getIntent().getStringExtra("url");
if (url == null) {
webView.loadData(getIntent().getStringExtra("html"), "text/html", "utf-8");
} else {
webView.loadUrl(url);
}
}
Example 9
Project: kanqiu_letv-master File: WebviewAnalytic.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.umeng_example_analytics_webview);
WebView webview = (WebView) findViewById(R.id.webview);
//important , so that you can use js to call Uemng APIs
new MobclickAgentJSInterface(this, webview, new WebChromeClient());
webview.loadUrl("file:///android_asset/demo.html");
}
Example 10
Project: LRecyclerView-master File: WebViewActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
final PullScrollView refreshLayout = (PullScrollView) findViewById(R.id.refresh_layout);
final WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());
//è®¾ç½®å¤´éƒ¨åŠ è½½é¢œè‰²
refreshLayout.setHeaderViewColor(R.color.colorAccent, R.color.dark, android.R.color.white);
refreshLayout.setRefreshProgressStyle(ProgressStyle.LineSpinFadeLoader);
refreshLayout.setRefreshListener(new PullScrollView.RefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
webView.loadUrl("http://www.stay4it.com");
refreshLayout.setRefreshCompleted();
}
}, 1000);
}
});
refreshLayout.refreshWithPull();
}
Example 11
Project: Path-of-Exile-Racer-master File: WebFragment.java View source code |
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
mCallback.onProgressChanged(newProgress);
}
});
}
Example 12
Project: Scrollable-master File: FragmentPagerFragmentWebView.java View source code |
@Override
public void onViewCreated(View view, Bundle sis) {
super.onViewCreated(view, sis);
mWebView = findView(R.id.web_view);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.post(new Runnable() {
@Override
public void run() {
mWebView.loadUrl("https://github.com/noties/Scrollable/tree/develop");
}
});
}
Example 13
Project: SlideBottomPanel-master File: MainActivity.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sbv = (SlideBottomPanel) findViewById(R.id.sbv);
tvEdit = (TextView) findViewById(R.id.tv_edit);
webView = (WebView) findViewById(R.id.wv_main);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(webUrl);
webView.setWebChromeClient(new WebChromeClient());
tvEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, InputActivity.class);
startActivity(intent);
}
});
}
Example 14
Project: TadpoleGame-master File: WebviewAnalytic.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.umeng_example_analytics_webview);
WebView webview = (WebView) findViewById(R.id.webview);
//important , so that you can use js to call Uemng APIs
new MobclickAgentJSInterface(this, webview, new WebChromeClient());
webview.loadUrl("file:///android_asset/demo.html");
}
Example 15
Project: ulti-master File: WebViewActivity.java View source code |
private void initWebView() {
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
WebSettings settings = mWebView.getSettings();
settings.setSavePassword(true);
settings.setSaveFormData(true);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setDomStorageEnabled(true);
settings.setSupportMultipleWindows(false);
mWebView.loadUrl("http://developer.android.com");
}
Example 16
Project: UltimateAndroid-master File: WebViewActivity.java View source code |
private void initWebView() {
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
WebSettings settings = mWebView.getSettings();
settings.setSavePassword(true);
settings.setSaveFormData(true);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setDomStorageEnabled(true);
settings.setSupportMultipleWindows(false);
mWebView.loadUrl("http://developer.android.com");
}
Example 17
Project: zhaoxinwo-android-master File: StatisticActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide title
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_statistic);
final WebView webView = (WebView) findViewById(R.id.webView);
webView.loadUrl((new ZApi()).getBaseUri() + "#/statistic");
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
final TextView textProgress = (TextView) findViewById(R.id.textProgress);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
textProgress.setText("åŠ è½½ä¸...(" + newProgress + "%)");
if (newProgress == 100) {
webView.setVisibility(View.VISIBLE);
textProgress.setVisibility(View.GONE);
} else {
webView.setVisibility(View.GONE);
textProgress.setVisibility(View.VISIBLE);
}
}
});
}
Example 18
Project: Alpha-Moon-master File: H5PViewerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Setting up full screen mode for kisok mode
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//////////////
setContentView(R.layout.h5p_viewer);
String content = getIntent().getExtras().getString("content");
this.nodeId = getIntent().getExtras().getInt("node_id");
this.contentId = getIntent().getExtras().getInt("content_id");
this.skillId = getIntent().getExtras().getInt("skill_id");
WebView browser = (WebView) findViewById(R.id.webview);
browser.setWebChromeClient(new WebChromeClient());
browser.setWebViewClient(new WebViewClient());
browser.getSettings().setAllowFileAccess(true);
browser.getSettings().setPluginState(PluginState.ON);
browser.getSettings().setBuiltInZoomControls(true);
browser.getSettings().setJavaScriptEnabled(true);
browser.loadUrl(content);
}
Example 19
Project: Amigo-master File: WebActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_web);
webview = (WebView) findViewById(R.id.web_view);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
webview.loadUrl("http://www.bing.com");
Log.d("web_activity", "onCreate: ");
}
Example 20
Project: Android-Debug-Tools-master File: WebViewActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
url = getIntent().getStringExtra("key");
setContentView(R.layout.activity_webview);
webView = (WebView) findViewById(R.id.webView1);
this.webView = (WebView) findViewById(R.id.webView1);
this.webView.setScrollBarStyle(0);
this.webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
this.webView.getSettings().setJavaScriptEnabled(true);
this.listenClient = new Client(WebViewActivity.this);
this.webView.setWebViewClient(this.listenClient);
this.webView.addJavascriptInterface(this.listenClient, "Android");
this.webView.setWebChromeClient(new WebChromeClient() {
// åŠ è½½å€’è®¡æ—¶
private CountDownTimer loadCDT = null;
@Override
public void onProgressChanged(final WebView view, int progress) {
}
});
this.webView.loadUrl(url);
}
Example 21
Project: Android-Pay-master File: TestOnlineActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_online);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
final WebView webView = (WebView) this.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
webView.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
webView.setWebChromeClient(new WebChromeClient() {
});
webView.loadUrl(DEFAULT_TEST_URL);
}
Example 22
Project: android-sync-master File: WebViewActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.sync_setup_webview);
// Extract URI to launch from Intent.
Uri uri = this.getIntent().getData();
if (uri == null) {
Logger.debug(LOG_TAG, "No URI passed to display.");
finish();
}
WebView wv = (WebView) findViewById(R.id.web_engine);
// Add a progress bar.
final Activity activity = this;
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 100);
}
});
wv.setWebViewClient(new WebViewClient() {
// Handle url loading in this WebView, instead of asking the ActivityManager.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
wv.loadUrl(uri.toString());
}
Example 23
Project: androidPublish-master File: WebViews.java View source code |
public static void setDisableJSChromeClient(WebView webView) {
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
MoPubLog.d(message);
result.confirm();
return true;
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
MoPubLog.d(message);
result.confirm();
return true;
}
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
MoPubLog.d(message);
result.confirm();
return true;
}
@Override
public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
MoPubLog.d(message);
result.confirm();
return true;
}
});
}
Example 24
Project: appboy-android-sdk-master File: AppboyInAppMessageHtmlFullView.java View source code |
@Override
public WebView getMessageWebView() {
if (mMessageWebView == null) {
mMessageWebView = (AppboyInAppMessageWebView) findViewById(R.id.com_appboy_inappmessage_html_full_webview);
if (mMessageWebView != null) {
WebSettings webSettings = mMessageWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
webSettings.setDisplayZoomControls(false);
// This enables hardware acceleration if the manifest also has it defined. If not defined, then the layer type will fallback to software
mMessageWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
mMessageWebView.setBackgroundColor(Color.TRANSPARENT);
// Set the client for console logging. See https://developer.android.com/guide/webapps/debugging.html
mMessageWebView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage cm) {
AppboyLogger.d(TAG, String.format("Html In-app log. Line: %s. SourceId: %s. Log Level: %s. Message: %s", cm.lineNumber(), cm.sourceId(), cm.messageLevel(), cm.message()));
return true;
}
});
mMessageWebView.addJavascriptInterface(new AppboyInAppMessageHtmlJavascriptInterface(getContext()), APPBOY_BRIDGE_PREFIX);
}
}
return mMessageWebView;
}
Example 25
Project: auid-master File: LoadingIndicatorFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mWebView = new WebView(inflater.getContext());
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
getActivity().setProgress(progress * 100);
}
});
return mWebView;
}
Example 26
Project: Bangumi-Android-master File: WebviewActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
mWebview = (WebView) findViewById(R.id.webview);
final ProgressView mProgress = (ProgressView) findViewById(R.id.progress);
WebSettings settings = mWebview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
mWebview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
ToastManager.show(WebviewActivity.this, description);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
});
mWebview.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress == 100) {
mProgress.setVisibility(View.GONE);
} else {
if (mProgress.getVisibility() == View.GONE) {
mProgress.setVisibility(View.VISIBLE);
}
mProgress.setProgress((float) (newProgress / 100.0));
}
}
});
String subjectUrl = getIntent().getStringExtra("subjectUrl");
if (subjectUrl != null) {
mWebview.loadUrl(subjectUrl);
} else {
mWebview.loadUrl(BangumiApi.URL_RAKUEN);
}
}
Example 27
Project: chromium_webview-master File: AwContentViewClient.java View source code |
@Override public void onShowCustomView(View view) { WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() { @Override public void onCustomViewHidden() { ContentVideoView contentVideoView = ContentVideoView.getContentVideoView(); if (contentVideoView != null) contentVideoView.exitFullscreen(false); } }; mAwContentsClient.onShowCustomView(view, cb); }
Example 28
Project: Devtf_APP-master File: ShowContentActivity.java View source code |
@Override
protected void init() {
if (null == rssItem) {
return;
}
webView.loadUrl(rssItem.getLink());
webView.clearCache(true);
WebSettings webSettings = webView.getSettings();
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
}
});
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
{
view.loadUrl(url);
return true;
}
}
});
}
Example 29
Project: earthquake-monitor-master File: HelpActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.webview);
WebView webView = (WebView) findViewById(R.id.webview);
webView.setWebViewClient(new BrowserActivityClient());
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
setProgress(progress * 100);
if (progress == 100) {
setProgressBarIndeterminateVisibility(false);
setProgressBarVisibility(false);
}
}
});
webView.loadUrl("file:///android_asset/help/index.html");
}
Example 30
Project: ele_demo-master File: DianPingWebActivity.java View source code |
private void initView() {
above_tittle.setText("¸½½üÍŹº");
head_left.setImageResource(R.drawable.abc_ic_ab_back_holo_dark);
mWebView.loadUrl("http://m.dianping.com/tuan");
// ʹÓÃwebviewä¯ÀÀÍøÒ³
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
}
});
}
Example 31
Project: FindLookManager-master File: WebActivity.java View source code |
public void init() {
if (Build.VERSION.SDK_INT >= 19) {
wsqWebView.getSettings().setLoadsImagesAutomatically(true);
} else {
wsqWebView.getSettings().setLoadsImagesAutomatically(false);
}
// -----------------------------------------------------------------
// 设置使用够执行JS脚本
wsqWebView.getSettings().setJavaScriptEnabled(true);
//wsqWebView.getSettings().setBuiltInZoomControls(true); // 设置使支�缩放
wsqWebView.getSettings().setDefaultFontSize(12);
wsqWebView.setWebChromeClient(new WebChromeClient());
wsqWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 使用当�WebView处�跳转
view.loadUrl(url);
// true表示æ¤äº‹ä»¶åœ¨æ¤å¤„被处ç?†ï¼Œä¸?需è¦?å†?广æ’
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if (!wsqWebView.getSettings().getLoadsImagesAutomatically()) {
wsqWebView.getSettings().setLoadsImagesAutomatically(true);
}
}
});
wsqWebView.loadUrl(url);
// ------------------------------------------------
}
Example 32
Project: Gazetti_Newspaper_Reader-master File: WebViewFragment.java View source code |
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setBuiltInZoomControls(true);
if (getArguments() != null) {
mURL = getArguments().getString("URL");
}
if (mURL != null) {
mWebView.loadUrl(mURL);
}
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
showProgressBar();
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
hideProgressBar();
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
setProgressBar(newProgress);
}
});
}
Example 33
Project: gina-puffinfeeder-android-viewer-master File: WebViewActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle url = getIntent().getExtras();
String pageUrl = url.getString("url", "https://github.com/404");
if (!pageUrl.substring(0, 5).equals("file:")) {
requestWindowFeature(Window.FEATURE_PROGRESS);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
}
setContentView(R.layout.activity_web_view);
WebView screen = (WebView) findViewById(R.id.info_web_view);
screen.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
try {
setProgress(newProgress * 100);
if (newProgress >= 0)
setProgressBarIndeterminate(false);
if (newProgress >= 100) {
setProgressBarVisibility(false);
setProgressBarIndeterminateVisibility(false);
}
} catch (NullPointerException e) {
Log.d(getString(R.string.app_tag), "ProgressBar NullPointer!\n" + Arrays.toString(e.getStackTrace()));
}
}
});
setProgressBarVisibility(true);
setProgressBarIndeterminate(true);
setProgressBarIndeterminateVisibility(true);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setTitle(url.getString("title", "Page not found - GitHub"));
}
screen.loadUrl(pageUrl);
}
Example 34
Project: go-go-master File: WebActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
String url = getIntent().getStringExtra(URL);
String title = getIntent().getStringExtra(TITLE);
initToolBar(toolbar, true, title);
pb.setMax(100);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
pb.setProgress(newProgress);
if (newProgress >= 100) {
pb.setVisibility(View.GONE);
}
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl(url);
}
Example 35
Project: HeaderViewPager-master File: WebViewFragment.java View source code |
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_webview, container, false);
webView = (WebView) view.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDisplayZoomControls(true);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl("https://github.com/jeasonlzy0216");
return view;
}
Example 36
Project: hpbpad-Android-master File: ReaderWebPageFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.reader_web_page, container, false);
wv = (WebView) v.findViewById(R.id.webView);
this.setDefaultWebViewSettings(wv);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wv.addJavascriptInterface(new JavaScriptInterface(getActivity().getApplicationContext()), interfaceNameForJS);
wv.setWebViewClient(new DetailWebViewClient());
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (getActivity() != null)
((ReaderActivity) getActivity()).setSupportProgress(progress * 100);
}
});
return v;
}
Example 37
Project: iFixitAndroid-master File: EmbedViewActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature((int) Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.embed_view);
Bundle extras = getIntent().getExtras();
mHTML = (String) extras.get(HTML);
mWebView = (WebView) findViewById(R.id.full_screen_web_view);
WebSettings settings = mWebView.getSettings();
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
settings.setAppCacheEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
mWebView.setWebChromeClient(new WebChromeClient() {
});
if (savedInstanceState != null) {
mWebView.restoreState(savedInstanceState);
}
mWebView.loadUrl(mHTML);
}
Example 38
Project: ItchDroid-master File: NewsActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news);
WebView webview = (WebView) findViewById(R.id.webViewNews);
progressBar = (ProgressBar) findViewById(R.id.progressBarWeb);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
progressBar.setProgress(progress);
// remove some of the tumblr crap that we don't want
view.loadUrl("javascript:(function(){ " + "try {" + " var header = document.getElementById('header');" + " header.style.display = 'none';" + " var hider = function(name) {" + " var a = document.getElementsByClassName(name); " + " var item;" + " for (var i = 0; i < a.length; ++i) {" + " item = a[i];" + " item.style.display = 'none';" + " }" + " };" + " hider('nav-menu-wrapper');" + " hider('nav-menu-bg');" + "} catch (e) { " + "}" + "})();");
}
});
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
webView.loadUrl(url);
return true;
}
});
webview.loadUrl("http://itchio.tumblr.com");
}
Example 39
Project: JekyllForAndroid-master File: MarkdownPreviewFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_markdown_preview, container, false);
// Find the webview
WebView webview = (WebView) rootView.findViewById(R.id.markdown_preview_view);
WebSettings settings = webview.getSettings();
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.setWebChromeClient(new WebChromeClient());
AndDown andDown = new AndDown();
String htmlData = andDown.markdownToHtml(content);
htmlData = "<meta name=\"HandheldFriendly\" content=\"True\">\n" + "<meta name=\"MobileOptimized\" content=\"320\">\n" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" + "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/main.min.css?family=Lato:300,400,700,300italic,400italic\" />" + "<meta http-equiv=\"cleartype\" content=\"on\">" + "<script src=\"js/vendor/modernizr-2.6.2.custom.min.js\"></script>" + htmlData;
webview.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "UTF-8", null);
return rootView;
}
Example 40
Project: JwZhangJie-master File: WebVideo.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webvideo);
MyWebView = (WebView) findViewById(R.id.webvideo_webview);
MyWebView.getSettings().setJavaScriptEnabled(true);
MyWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
});
MyWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
});
MyWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
MyWebView.loadUrl("http://www.google.hk");
}
Example 41
Project: KeepGank-master File: WebView.java View source code |
private void initWebView() {
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(android.webkit.WebView view, String url) {
//返回值是true的时候控制去WebView打开,为false调用系统�览器或第三方�览器
view.loadUrl(url);
return true;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(android.webkit.WebView view, int newProgress) {
if (newProgress == 100) {
// ç½‘é¡µåŠ è½½å®Œæˆ?
if (mProgressBar != null) {
mProgressBar.setVisibility(View.GONE);
mProgressBar.setProgress(0);
}
} else {
// åŠ è½½ä¸
if (mProgressBar != null) {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(newProgress);
}
}
}
});
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setDisplayZoomControls(true);
}
Example 42
Project: Klyph-master File: FaqActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_PROGRESS);
super.onCreate(savedInstanceState);
setTitle(R.string.menu_faq);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
setProgress(progress * 1000);
}
});
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(FaqActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
webView.loadUrl(FAQ_URL);
}
Example 43
Project: KlyphMessenger-master File: FaqActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_PROGRESS);
super.onCreate(savedInstanceState);
setTitle(R.string.menu_faq);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
setProgress(progress * 1000);
}
});
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(FaqActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
webView.loadUrl(FAQ_URL);
}
Example 44
Project: ListItemFold-master File: DetailFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_blank, container, false);
mWebview = (WebView) view.findViewById(R.id.h5_web);
WebSettings webSettings = mWebview.getSettings();
webSettings.setSupportZoom(false);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setLoadWithOverviewMode(true);
webSettings.setJavaScriptEnabled(true);
mWebview.setWebChromeClient(new WebChromeClient());
mWebview.setWebViewClient(new WebViewClient());
mWebview.loadUrl(mUrl);
DetailAnimViewGroup wrapper = new DetailAnimViewGroup(inflater.getContext(), view, 0);
wrapper.setReversed(false);
return wrapper;
}
Example 45
Project: materialistic-master File: ReleaseNotesActivity.java View source code |
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_release);
findViewById(R.id.button_ok).setOnClickListener( v -> finish());
findViewById(R.id.button_rate).setOnClickListener( v -> {
AppUtils.openPlayStore(this);
finish();
});
WebView webView = (WebView) findViewById(R.id.web_view);
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
webView.setBackgroundColor(Color.TRANSPARENT);
webView.loadDataWithBaseURL(null, getString(R.string.release_notes, AppUtils.toHtmlColor(this, android.R.attr.textColorPrimary), AppUtils.toHtmlColor(this, android.R.attr.textColorLink)), "text/html", "UTF-8", null);
Preferences.setReleaseNotesSeen(this);
}
Example 46
Project: miris-master File: DetailFragment.java View source code |
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_detail, null);
final WebView webView = (WebView) view.findViewById(R.id.webView);
final ProgressBar home_progressbar = (ProgressBar) view.findViewById(R.id.home_progressbar);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.loadUrl(urlName);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
home_progressbar.setVisibility(View.VISIBLE);
if (newProgress == 100) {
home_progressbar.setProgress(newProgress);
home_progressbar.setVisibility(View.GONE);
}
home_progressbar.setProgress(newProgress);
}
});
return view;
}
Example 47
Project: MobFox-Android-SDK-master File: InAppWebView.java View source code |
private void initializeWebView(Intent intent) {
WebView webView = new WebView(this);
this.setContentView(webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Activity a = (Activity) view.getContext();
Toast.makeText(a, "MRAID error: " + description, Toast.LENGTH_SHORT).show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url == null)
return false;
Uri uri = Uri.parse(url);
String host = uri.getHost();
if ((url.startsWith("http:") || url.startsWith("https:")) && !"play.google.com".equals(host) && !"market.android.com".equals(host)) {
view.loadUrl(url);
return true;
}
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch (ActivityNotFoundException exception) {
}
finish();
return true;
}
});
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
Activity a = (Activity) view.getContext();
a.setTitle("Loading...");
a.setProgress(progress * 100);
if (progress == 100)
a.setTitle(view.getUrl());
}
});
webView.loadUrl(intent.getStringExtra(Const.REDIRECT_URI));
}
Example 48
Project: MySnippetRepo-master File: UserLoginActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.layout_userlogin);
setTitle("载入ä¸");
webInstance = this;
webView = (WebView) findViewById(R.id.user_login);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
/* webSettings.setSaveFormData(true);*/
webSettings.setSavePassword(true);
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
webView.requestFocus();
return false;
}
});
intent = this.getIntent();
if (!intent.equals(null)) {
Bundle b = intent.getExtras();
if (b != null && b.containsKey("url")) {
webView.loadUrl(b.getString("url"));
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
setTitle("æ£åœ¨ä¸ºæ‚¨è½½å…¥..." + progress + "%");
setProgress(progress * 100);
if (progress == 100)
setTitle(R.string.app_name);
}
});
}
}
}
Example 49
Project: naruto-master File: AboutActivity.java View source code |
private void initWebview() {
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
loadingview.loadingSuccess();
}
public void onFormResubmission(WebView view, Message dontResend, Message resend) {
resend.sendToTarget();
}
});
webView.setWebChromeClient(new WebChromeClient() {
});
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
}
});
}
Example 50
Project: OdyAndroidStore-master File: WebActivity.java View source code |
@Override
protected void initView() {
wv = (WebView) findViewById(R.id.wv);
titleTxt = (TextView) findViewById(R.id.title);
ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
super.onReceivedSslError(view, handler, error);
}
});
wv.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
if (!StringUtils.isEmpty(title)) {
titleTxt.setText(title);
}
}
});
}
Example 51
Project: okhttp-OkGo-master File: WebActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
String url = getIntent().getStringExtra(URL);
String title = getIntent().getStringExtra(TITLE);
initToolBar(toolbar, true, title);
pb.setMax(100);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
pb.setProgress(newProgress);
if (newProgress >= 100) {
pb.setVisibility(View.GONE);
}
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl(url);
}
Example 52
Project: phphub-android-master File: WebViewPageActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
urlString = getIntent().getStringExtra(WEB_URL);
toolbarTitleView.setText(getString(R.string.loading));
String userAgent = String.format("%s PHPHubBroswer/%s", getUserAgent(), BuildConfig.VERSION_NAME);
contentView.setWebViewClient(new WebAppClient(this, navigator, multiStateView, contentView));
settings.setUserAgentString(userAgent);
settings.setJavaScriptEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDefaultTextEncodingName("utf-8");
settings.setDomStorageEnabled(true);
contentView.loadUrl(urlString);
contentView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
toolbarTitleView.setText(title);
}
});
}
Example 53
Project: prey-android-client-master File: PanelWebActivity.java View source code |
@Override
public void onResume() {
super.onResume();
WebSettings settings = myWebView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
myWebView.setVerticalScrollBarEnabled(false);
myWebView.setHorizontalScrollBarEnabled(false);
myWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100)
activity.setTitle(R.string.app_name);
}
});
myWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
PreyLogger.d("Finished:" + url);
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
PreyLogger.d("Started:" + url);
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
PreyLogger.d("OverrideUrl:" + url);
return super.shouldOverrideUrlLoading(view, url);
}
});
String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelJwt();
String postData = "token=" + PreyConfig.getPreyConfig(getApplicationContext()).getTokenJwt();
;
byte[] postByte = EncodingUtils.getBytes(postData, "BASE64");
myWebView.postUrl(url, postByte);
}
Example 54
Project: QSCMobileLegacy-master File: PluginDetailActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.plugin_activity);
String ID = getIntent().getStringExtra("ID");
if (ID == null) {
finish();
return;
}
PluginStructure structure = new PluginStructure(ID, this);
webView = (WebView) findViewById(R.id.card_webview);
webView.getSettings().setJavaScriptEnabled(true);
JSInterface jsInterface = new JSInterface(this, webView, null);
jsInterface.init();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
}
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
LogHelper.e(consoleMessage.message());
return super.onConsoleMessage(consoleMessage);
}
});
LogHelper.e("file:" + new File(getFilesDir(), PlatformUpdateHelper.PATH_ADD + structure.path + "/index.html").getAbsolutePath());
webView.loadUrl("file:" + new File(getFilesDir(), PlatformUpdateHelper.PATH_ADD + structure.path + "/index.html").getAbsolutePath());
}
Example 55
Project: school_shop-master File: WebViewActivity.java View source code |
private void initView() {
webView = (WebView) findViewById(R.id.webview);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
url = getIntent().getExtras().getString("url");
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setWebViewClient(new MyWebViewClient());
webView.setWebChromeClient(new WebChromeClient() {
// 更新进度�
@Override
public void onProgressChanged(WebView view, int progress) {
progressBar.setProgress(progress);
if (progress == 100)
progressBar.setVisibility(View.GONE);
}
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
}
});
}
Example 56
Project: SealBrowser-master File: AwContentViewClient.java View source code |
@Override public void onShowCustomView(View view) { WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() { @Override public void onCustomViewHidden() { ContentVideoView contentVideoView = ContentVideoView.getContentVideoView(); if (contentVideoView != null) contentVideoView.exitFullscreen(false); } }; mAwContentsClient.onShowCustomView(view, cb); }
Example 57
Project: shop-master File: WsqActivity.java View source code |
public void init() {
if (Build.VERSION.SDK_INT >= 19) {
wsqWebView.getSettings().setLoadsImagesAutomatically(true);
} else {
wsqWebView.getSettings().setLoadsImagesAutomatically(false);
}
// -----------------------------------------------------------------
// 设置使用够执行JS脚本
wsqWebView.getSettings().setJavaScriptEnabled(true);
//wsqWebView.getSettings().setBuiltInZoomControls(true); // 设置使支�缩放
wsqWebView.getSettings().setDefaultFontSize(12);
wsqWebView.setWebChromeClient(new WebChromeClient());
wsqWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 使用当�WebView处�跳转
view.loadUrl(url);
// true表示æ¤äº‹ä»¶åœ¨æ¤å¤„被处ç?†ï¼Œä¸?需è¦?å†?广æ’
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if (!wsqWebView.getSettings().getLoadsImagesAutomatically()) {
wsqWebView.getSettings().setLoadsImagesAutomatically(true);
}
}
});
wsqWebView.loadUrl(URL_WSQ);
// ------------------------------------------------
}
Example 58
Project: TLRLoadRefresh-master File: RWebViewActivity.java View source code |
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tlrwebview);
mProgressBar = (ProgressBar) findViewById(R.id.progress);
mTLRLinearLayout = (TLRLinearLayout) findViewById(R.id.tlrlayout);
mTLRLinearLayout.addTLRUiHandler(new TLRUIHandlerAdapter() {
@Override
public void onRefreshStatusChanged(View target, TLRLinearLayout.RefreshStatus status) {
if (status == TLRLinearLayout.RefreshStatus.REFRESHING) {
if (refreshCount % 2 == 0) {
mWebView.loadUrl("https://developers.google.cn/");
} else {
mWebView.loadUrl("https://developer.android.google.cn/index.html");
}
refreshCount++;
}
}
});
mWebView = (WebView) findViewById(R.id.content);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mTLRLinearLayout.finishRefresh(true);
}
}, 1500);
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mTLRLinearLayout.finishRefresh(false);
}
}, 1500);
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress == 0 || newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setVisibility(View.VISIBLE);
}
mProgressBar.setProgress(newProgress);
}
});
}
Example 59
Project: training-content-master File: MyBrowserActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_browser);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
extras = getIntent().getExtras();
if (extras != null) {
urlToLoad = extras.getString(ARG_URL);
}
progressBar = (ProgressBar) findViewById(R.id.progressbar);
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// Show progressbar
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Show error
// Stop spinner or progressbar
progressBar.setVisibility(View.GONE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// Stop spinner or progressBar
progressBar.setVisibility(View.GONE);
}
});
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
progressBar.setProgress(progress * 100);
}
});
webView.loadUrl(urlToLoad);
}
Example 60
Project: UltimateRefreshView-master File: WebViewFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_web_view, container, false);
WebView mWebView = (WebView) view.findViewById(R.id.webview);
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl("https://www.baidu.com");
mUltimateRefreshView = (UltimateRefreshView) view.findViewById(R.id.refreshView);
mUltimateRefreshView.setBaseHeaderAdapter(new SimpleHeaderAdapter(getContext()));
mUltimateRefreshView.setOnHeaderRefreshListener(new OnHeaderRefreshListener() {
@Override
public void onHeaderRefresh(UltimateRefreshView view) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mUltimateRefreshView.onHeaderRefreshComplete();
}
}, 2000);
}
});
return view;
}
Example 61
Project: Wordpress-Android-App-master File: WPCOMReaderWebPage.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.reader_web_page, container, false);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
wv = (WebView) v.findViewById(R.id.webView);
this.setDefaultWebViewSettings(wv);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wv.addJavascriptInterface(new JavaScriptInterface(getActivity().getApplicationContext()), interfaceNameForJS);
wv.setWebViewClient(new DetailWebViewClient());
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
progressBar.setProgress(progress);
if (progress == 100)
progressBar.setVisibility(View.GONE);
}
});
return v;
}
Example 62
Project: WordPress-Android-master File: ReaderVideoViewerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reader_activity_video_player);
mWebView = (WebView) findViewById(R.id.web_view);
mProgress = (ProgressBar) findViewById(R.id.progress);
mWebView.setBackgroundColor(Color.TRANSPARENT);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setUserAgentString(WordPress.getUserAgent());
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (progress == 100) {
mProgress.setVisibility(View.GONE);
} else {
mProgress.setProgress(progress);
if (mProgress.getVisibility() != View.VISIBLE) {
mProgress.setVisibility(View.VISIBLE);
}
}
}
});
if (savedInstanceState == null) {
mVideoUrl = getIntent().getStringExtra(ReaderConstants.ARG_VIDEO_URL);
mWebView.loadUrl(mVideoUrl);
} else {
mVideoUrl = savedInstanceState.getString(ReaderConstants.ARG_VIDEO_URL);
mWebView.restoreState(savedInstanceState);
}
}
Example 63
Project: xifan-master File: BrowserActivity.java View source code |
@Override
protected void initViews() {
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(request.getUrl().toString());
return true;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
mToolbar.setTitle(title);
}
});
if (!TextUtils.isEmpty(mUrl)) {
mWebView.loadUrl(mUrl);
}
}
Example 64
Project: AcFun-Area63-master File: DonateActivity.java View source code |
@Override
protected void initView(Bundle savedInstanceState) {
super.initView(savedInstanceState);
mWeb.setWebChromeClient(new WebChromeClient());
mWeb.getSettings().setUserAgentString(UA);
mWeb.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(uri);
if ("alipayqr".equals(uri.getScheme()) || "alipays".endsWith(uri.getScheme())) {
try {
startActivity(intent);
finish();
} catch (Exception e) {
e.printStackTrace();
showErrorDialog();
}
return true;
} else if (url.startsWith("http") && url.endsWith(".apk")) {
startActivity(intent);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
setSupportProgressBarIndeterminateVisibility(false);
}
});
}
Example 65
Project: ActionsContentView-master File: WebViewFragment.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.webview, container, false);
final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress);
viewContentWebView = (WebView) v.findViewById(R.id.webview);
viewContentWebView.getSettings().setJavaScriptEnabled(true);
viewContentWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
});
viewContentWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
viewContentProgress.setProgress(newProgress);
viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);
if (newProgress == 100 && resetHistory) {
viewContentWebView.clearHistory();
resetHistory = false;
}
}
});
return v;
}
Example 66
Project: advanced-tourist-map-master File: WikiOverlayItem.java View source code |
@Override
public void onTap(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
LayoutInflater factory = LayoutInflater.from(context);
final View dialogView = factory.inflate(R.layout.webview_dialog, null);
builder.setTitle(article.getTitle());
// a progress bar to indicate loading
final ProgressBar progressBar = (ProgressBar) dialogView.findViewById(R.id.webview_dialog_progress);
WebView webView = (WebView) dialogView.findViewById(R.id.webview_dialog_webview);
// handle link clicks internally (doesn't open new browser window)
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);
return false;
}
});
// show loading progress
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
if (progress == 100) {
progressBar.setVisibility(View.GONE);
} else {
progressBar.setProgress(progress);
}
}
});
// let the article set what to render (load url or local data)
article.setWebView(webView);
builder.setView(dialogView);
builder.setPositiveButton("Info", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, PositionInfo.class).putExtra(PositionInfo.LATITUDE_EXTRA, article.getLat()).putExtra(PositionInfo.LONGITUDE_EXTRA, article.getLng()));
}
});
builder.setNegativeButton("Close", null);
builder.show();
}
Example 67
Project: Android-Funny-Feed-master File: VideoActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
setContentView(R.layout.view_youtube);
Button btnClose = (Button) findViewById(R.id.btnClose);
btnClose.setOnTouchListener(CustomButtonTouchListener.getInstance());
btnClose.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
onBackPressed();
}
});
String url = getIntent().getStringExtra("youtube_url");
final WebView mWebView = (WebView) findViewById(R.id.webview);
WebSettings settings = mWebView.getSettings();
// settings.setBuiltInZoomControls(true);
// settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
// settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setJavaScriptEnabled(true);
settings.setPluginState(WebSettings.PluginState.ON);
mWebView.setWebChromeClient(new WebChromeClient() {
});
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// return true;
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
progressBar.setVisibility(View.VISIBLE);
super.onPageStarted(view, url, favicon);
}
public void onPageFinished(WebView view, String url) {
progressBar.setVisibility(View.GONE);
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(VideoActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
mWebView.loadUrl(url);
}
Example 68
Project: android-sdk-sources-for-api-level-23-master File: LooperAcceleration.java View source code |
private View makeView() {
LinearLayout layout = new LinearLayout(this);
layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
if (INCLUDE_WEBVIEW) {
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient());
wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
return layout;
}
Example 69
Project: AndroidExercise-master File: MainActivity.java View source code |
@SuppressLint("JavascriptInterface")
private void initWebView() {
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
webView.addJavascriptInterface(new WebHost(MainActivity.this), "js");
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
tvTopTitle.setText(title);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
view.loadUrl("file:///android_asset/error.html");
}
});
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Log.i(TAG, "downloadUrl--->" + url);
if (url.endsWith(".apk")) {
//开�线程下载
// new HttpThread(url).start();
//调用系统下载
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
}
});
}
Example 70
Project: AndroidFire-master File: NewsBrowserActivity.java View source code |
private void setWebView() {
webView.loadUrl(getIntent().getStringExtra(AppConstant.NEWS_LINK));
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null)
view.loadUrl(url);
return true;
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress == 100) {
progressBar.setVisibility(View.GONE);
} else {
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(newProgress);
}
}
});
}
Example 71
Project: AndroidProjectStroe-master File: Goods_DescAty.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyApplication.getInstance().addActivity(this);
setContentView(R.layout.p2_main_webview);
ViewUtils.inject(this);
String desc = getIntent().getStringExtra("desc");
String html = "<html>" + "<body>" + desc + "</body>" + "</html>";
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setHorizontalScrollBarEnabled(true);
webView.setHorizontalScrollbarOverlay(true);
webView.setInitialScale(10);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
DisplayMetrics dm = getResources().getDisplayMetrics();
int scale = dm.densityDpi;
if (//
scale == //
240) {
webView.getSettings().setDefaultZoom(ZoomDensity.FAR);
} else if (scale == 160) {
webView.getSettings().setDefaultZoom(ZoomDensity.MEDIUM);
} else {
webView.getSettings().setDefaultZoom(ZoomDensity.CLOSE);
}
webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
img_Back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
tv_Car.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AtyUtils.turnToCar(Goods_DescAty.this);
}
});
}
Example 72
Project: android_frameworks_base-master File: LooperAcceleration.java View source code |
private View makeView() {
LinearLayout layout = new LinearLayout(this);
layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
if (INCLUDE_WEBVIEW) {
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient());
wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
return layout;
}
Example 73
Project: aptoide-client-master File: WebViewTwitter.java View source code |
public void onCreate(Bundle savedInstanceState) {
//Aptoide.getThemePicker().setAptoideTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_social);
url = "http://mobile.twitter.com/aptoide";
try {
waitingText = (TextView) findViewById(R.id.waiting_text);
waitingBar = (ProgressBar) findViewById(R.id.waiting_bar);
TwitterWebView = (WebView) findViewById(R.id.webview);
TwitterWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
TwitterWebView.getSettings().setJavaScriptEnabled(true);
// TwitterWebView.getSettings().setDomStorageEnabled(true);
TwitterWebView.getSettings().setSavePassword(false);
TwitterWebView.getSettings().setSaveFormData(false);
TwitterWebView.getSettings().setSupportZoom(false);
TwitterWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
setProgress(progress * 100);
if (progress == 100) {
waitingText.setVisibility(View.GONE);
waitingBar.setVisibility(View.GONE);
}
}
});
TwitterWebView.loadUrl(url);
} catch (Exception e) {
e.printStackTrace();
}
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setCollapsible(false);
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("");
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
Example 74
Project: AugmentedOxford-master File: M_WebView.java View source code |
@Override
public View getView(final Context context) {
WebView w = new WebView(context);
w.getSettings().setBuiltInZoomControls(useDefaultZoomControls);
if (useTransparentBackground)
w.setBackgroundColor(0x00000000);
w.getSettings().setJavaScriptEnabled(true);
w.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
onPageLoadProgress(progress * 100);
}
});
w.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null && url.startsWith("market://")) {
try {
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
context.startActivity(marketIntent);
return true;
} catch (Exception e) {
}
}
view.loadUrl(url);
// then it is not handled by
return dontLoadUrlInWebview(url);
// default action
}
@Override
public void onPageFinished(WebView view, String url) {
CookieSyncManager.getInstance().sync();
view.loadUrl("javascript:window.HTMLOUT.processHTML(" + "document.getElementsByTagName(" + "'body')[0].innerHTML);");
}
});
w.addJavascriptInterface(new Object() {
@SuppressWarnings("unused")
public void processHTML(String html) {
onPageLoaded(html);
}
}, "HTMLOUT");
w.clearView();
w.loadUrl(getUrlToDisplay());
return w;
}
Example 75
Project: AusSnowCam-master File: CamViewer.java View source code |
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
webview = (WebView) mContentView.findViewById(R.id.webview);
webview.setWebViewClient(new MyWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.setInitialScale(150);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
getActivity().setTitle(getString(R.string.loading));
getActivity().setProgress(progress * 100);
if (progress == 100) {
getActivity().setTitle(getString(R.string.app_name));
}
}
});
}
Example 76
Project: banya-master File: WebviewActivity.java View source code |
private void initView() {
toolbar.setBackgroundColor(ThemeUtils.getThemeColor());
toolbar.setNavigationIcon(R.drawable.back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
backThActivity();
}
});
WebSettings settings = webview.getSettings();
// 支�JS
settings.setJavaScriptEnabled(true);
//settings.setBuiltInZoomControls(true);// 显示放大缩�按钮
//settings.setUseWideViewPort(true);// 支��击放大缩�
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
/**
* 所有跳转的链接都在æ¤æ–¹æ³•ä¸å›žè°ƒ
*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
webview.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) {
toolbar.setTitle(title);
super.onReceivedTitle(view, title);
}
});
webview.loadUrl(url);
}
Example 77
Project: CookMe-master File: RecipeViewer.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.recipe_viewer);
Intent intent = getIntent();
recipe = intent.getStringArrayExtra("com.lcneves.cookme.RECIPE");
name = recipe[0];
url = recipe[2];
webview = (WebView) findViewById(R.id.webView);
setTitle(name);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Loading error: " + description, Toast.LENGTH_LONG).show();
}
});
Log.d("com.lcneves.cookme.RecipeViewer", url);
webview.loadUrl(url);
}
Example 78
Project: DevJobs-master File: JobWebViewFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_job_web_view, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.web_toolbar);
mProgressBar = (ProgressBar) rootView.findViewById(R.id.web_view_progress_bar);
mProgressBar.setMax(100);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
activity.getSupportActionBar().setHomeButtonEnabled(true);
activity.getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
activity.getSupportActionBar().setTitle(R.string.app_name);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
WebView webView = (WebView) rootView.findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.loadUrl(getArguments().getString(ARG_URL_KEY));
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView webview, int newProgress) {
if (newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(newProgress);
}
}
public void onReceivedTitle(WebView webView, String title) {
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.getSupportActionBar().setSubtitle(title);
}
});
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
return rootView;
}
Example 79
Project: ECMobile_Android-master File: BannerWebActivity.java View source code |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pay_web); Intent intent = getIntent(); String url = intent.getStringExtra("url"); title = (TextView) findViewById(R.id.top_view_text); Resources resource = (Resources) getBaseContext().getResources(); String bro = resource.getString(R.string.browser); title.setText(bro); back = (ImageView) findViewById(R.id.top_view_back); back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); webView = (WebView) findViewById(R.id.pay_web); webView.setWebViewClient(new // 通过webView打开链接,�调用系统�览器 WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); webView.setInitialScale(25); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setLoadWithOverviewMode(true); webView.loadUrl(url); WebChromeClient webChromeClient = new WebChromeClient() { @Override public void onReceivedTitle(WebView view, String str) { super.onReceivedTitle(view, str); title.setText(str); } }; webView.setWebChromeClient(webChromeClient); web_back = (ImageView) findViewById(R.id.web_back); web_back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (webView.canGoBack()) { webView.goBack(); } else { } } }); goForward = (ImageView) findViewById(R.id.goForward); goForward.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { webView.goForward(); } }); reload = (ImageView) findViewById(R.id.reload); reload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { webView.reload(); } }); }
Example 80
Project: fighter-master File: WebViewTest.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webkit);
webView.getSettings().setJavaScriptEnabled(true);
webView.requestFocus();
webView.setWebChromeClient(new WebChromeClient());
webView.setWebChromeClient(new MyWebChromeClient());
webView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
// �����¿�Android��ϵͳbrowser����Ӧ������
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl("file:///android_asset/AN/index.html");
}
Example 81
Project: find-sec-bugs-master File: GeolocationDetector.java View source code |
@Override public void visitClassContext(ClassContext classContext) { JavaClass javaClass = classContext.getJavaClass(); //The class extends WebChromeClient boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient"); //Not the target of this detector if (!isWebChromeClient) { return; } Method[] methodList = javaClass.getMethods(); for (Method m : methodList) { if (DEBUG) { System.out.println(">>> Method: " + m.getName()); } //The presence of onGeolocationPermissionsShowPrompt is not enforce for the moment if (!m.getName().equals("onGeolocationPermissionsShowPrompt")) { continue; } //Since the logic implemented need to be analyze by a human, all implementation will be flagged. bugReporter.reportBug(// new BugInstance(this, ANDROID_GEOLOCATION_TYPE, Priorities.NORMAL_PRIORITY).addClassAndMethod(javaClass, m)); } }
Example 82
Project: funwithmusic-master File: WebActivity.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
setContentView(R.layout.activity_web);
webView = (WebView) findViewById(R.id.webview);
Intent intent = getIntent();
url = intent.getStringExtra(WEB_URL);
//Log.d("URL", url);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
// String ua =
// "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
// webView.getSettings().setUserAgentString(ua);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different
// scales.
// The progress meter will automatically disappear when we reach
// 100%
WebActivity.this.setProgress(progress * 100);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// YouTube video link
if (url.startsWith("vnd.youtube:")) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://www.youtube.com/v/%s", url.substring("vnd.youtube:".length())))));
return true;
}
return false;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(WebActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
webView.loadUrl(url);
}
Example 83
Project: GankWithZhihu-master File: GankWebPresenter.java View source code |
public void setWebView(String url) {
IGankWebView urlView = getView();
ProgressBar progressBar = urlView.getProgressBar();
WebView webView = urlView.getWebView();
WebSettings settings = webView.getSettings();
// 支�JS
settings.setJavaScriptEnabled(true);
// 显示放大缩�按钮
settings.setBuiltInZoomControls(true);
// 支��击放大缩�
settings.setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
System.out.println("ç½‘é¡µå¼€å§‹åŠ è½½");
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
System.out.println("ç½‘é¡µåŠ è½½ç»“æ?Ÿ");
progressBar.setVisibility(View.GONE);
}
/**
* 所有跳转的链接都在æ¤æ–¹æ³•ä¸å›žè°ƒ
*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
progressBar.setProgress(newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) {
System.out.println("网页title:" + title);
activity.setTitle(title);
super.onReceivedTitle(view, title);
}
});
webView.loadUrl(url);
}
Example 84
Project: ijoomer-adv-sdk-master File: IjoomerCometChat.java View source code |
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
public void prepareViews() {
((TextView) getHeaderView().findViewById(R.id.txtHeader)).setText(getScreenCaption());
getIntentData();
final SeekBar seekBar = IjoomerUtilities.getLoadingDialog(getString(R.string.dialog_loading_please_wait));
webExternalLinks.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
seekBar.setProgress(progress);
}
});
webExternalLinks.setWebViewClient(new WebViewClient());
webExternalLinks.getSettings().setJavaScriptEnabled(true);
webExternalLinks.getSettings().setPluginState(PluginState.ON);
if (!link.startsWith("http://") && !link.startsWith("https://")) {
link = "http://" + link;
}
webExternalLinks.loadUrl(link);
btnClose.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
Example 85
Project: JustWeTools-master File: MarkDownView.java View source code |
private void init(Context context) {
this.context = context;
progressDialog = ProgressDialog.show(context, "请ç‰å¾…", "æ£åœ¨è½½å…¥...", true);
this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
this.getSettings().setBuiltInZoomControls(true);
this.getSettings().setDisplayZoomControls(false);
this.getSettings().setJavaScriptEnabled(true);
this.getSettings().setLoadWithOverviewMode(true);
this.getSettings().setUseWideViewPort(true);
this.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.getSettings().setAppCacheEnabled(true);
this.getSettings().setCacheMode(this.getSettings().LOAD_CACHE_ELSE_NETWORK);
loadUrl(LOAD_HTML);
this.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress >= 100 && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
});
}
Example 86
Project: KhanAcademy-LearnAnything-master File: WebpageFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_webpage, parent, false);
if (NavUtils.getParentActivityName(getActivity()) != null) {
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
}
final ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
progressBar.setMax(100);
mWebView = (WebView) v.findViewById(R.id.webView);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith(FORWARDING_URL)) {
try {
HashMap<String, String> queryMap = getQueryMap(new URL(url).getQuery());
view.loadUrl(OAuthClient.authenticate(queryMap.get("oauth_token")));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
} else {
view.loadUrl(url);
}
return true;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView webView, int progress) {
if (progress == 100) {
progressBar.setVisibility(View.INVISIBLE);
} else {
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(progress);
}
}
});
mWebView.loadUrl(mUrl);
return v;
}
Example 87
Project: likequanmintv-master File: WebContainerActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_web_container);
SystemBarUtils.setStatusBarTranslate(this, R.color.colorPrimary);
imgBack = (ImageView) findViewById(R.id.imgBack);
imgForward = (ImageView) findViewById(R.id.imgForward);
tvTitle = (TextView) findViewById(R.id.title);
imgBack.setOnClickListener(this);
imgForward.setOnClickListener(this);
mWebView = (WebView) findViewById(R.id.mWebView);
Bundle bundle = getIntent().getExtras();
if (null != bundle) {
title = bundle.getString(Intent.EXTRA_TITLE, "全民tv");
url = bundle.getString(Intent.EXTRA_TEXT, "");
isAd = bundle.getBoolean("isAd", false);
tvTitle.setText("" + title);
}
if (isAd) {
imgForward.setVisibility(View.VISIBLE);
imgBack.setVisibility(View.GONE);
}
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient());
WebSettings settings = mWebView.getSettings();
//�许使用js
settings.setJavaScriptEnabled(true);
//支�缩放
settings.setSupportZoom(true);
// //出现缩放工具
settings.setBuiltInZoomControls(true);
//
settings.setUseWideViewPort(true);
//
settings.setLoadWithOverviewMode(true);
//让网页自适应�幕宽度
// settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mWebView.loadUrl(url);
}
Example 88
Project: LoveWallpaper-master File: WebViewActivity.java View source code |
private void initView() {
mWebView = (WebView) findViewById(R.id.mWebView);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
Intent intent = getIntent();
title = intent.getStringExtra("title");
url = intent.getStringExtra("url");
if (!TextUtils.isEmpty(title)) {
getSupportActionBar().setTitle(title);
} else {
getSupportActionBar().setTitle("åŠ è½½å¤±è´¥");
}
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
WebSettings seting = mWebView.getSettings();
//设置webview支�javascript脚本
seting.setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress == 100) {
//åŠ è½½å®Œç½‘é¡µè¿›åº¦æ?¡æ¶ˆå¤±
progressBar.setVisibility(View.GONE);
} else {
//å¼€å§‹åŠ è½½ç½‘é¡µæ—¶æ˜¾ç¤ºè¿›åº¦æ?¡
progressBar.setVisibility(View.VISIBLE);
//设置进度值
progressBar.setProgress(newProgress);
}
}
});
if (!TextUtils.isEmpty(url)) {
mWebView.loadUrl(url);
} else {
L.e("url error");
}
}
Example 89
Project: MozStumbler-master File: LeaderboardActivity.java View source code |
@Override
protected void onStart() {
super.onStart();
setSupportProgressBarVisibility(true);
final Activity activity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
setSupportProgress(progress * 100);
if (progress > 45 && !mHasError) {
mWebView.setVisibility(View.VISIBLE);
}
if (progress > 90) {
setSupportProgressBarVisibility(false);
}
}
});
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
mHasError = true;
Toast.makeText(activity, "The Leaderboard requires an Internet connection.", Toast.LENGTH_LONG).show();
}
@Override
public void onPageFinished(WebView webview, String url) {
if (!mHasError) {
mWebView.setVisibility(View.VISIBLE);
}
setSupportProgressBarVisibility(false);
}
});
setProgress(0);
ClientPrefs prefs = ClientPrefs.getInstance(this);
URI tmpURI = null;
String url = null;
try {
tmpURI = new URI(prefs.getLbBaseURI() + "/?profile=" + prefs.getLeaderboardUID());
url = tmpURI.normalize().toString();
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "Error normalizing URL", e);
url = prefs.getLbBaseURI();
}
mWebView.loadUrl(url);
}
Example 90
Project: NTU_APP-master File: ShareActivityFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO Auto-generated method stub
v = inflater.inflate(R.layout.fragment_shareactivity, container, false);
mWebView = (WebView) v.findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
handler.sendEmptyMessage(1);
return true;
}
return false;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
final NumberProgressBar bnp = (NumberProgressBar) v.findViewById(R.id.number_progress_bar);
bnp.setProgressTextVisibility(NumberProgressBar.ProgressTextVisibility.Visible);
bnp.setProgress(progress);
if (progress == 100) {
bnp.setProgressTextVisibility(NumberProgressBar.ProgressTextVisibility.Invisible);
}
}
});
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//è¨ç½®é»žæ“Šç¶²é ?裡é?¢çš„é?ˆæŽ¥é‚„是在當å‰?çš„webview裡跳轉
view.loadUrl(url);
return true;
}
});
mWebView.loadUrl("https://ntu-activities.herokuapp.com/activities/new");
return v;
}
Example 91
Project: openxface-android-master File: XInAppWebView.java View source code |
/**
* �始化InAppWebView,对布局�行为�支�的特性进行�始化
* @param url
*/
private void init(String url, final XIWebContext webContext) {
setLayoutParams(new LinearLayout.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));
setWebChromeClient(new WebChromeClient());
setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
mListener.onLoadFinished(url, webContext);
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
mListener.onLoadStart(url, webContext);
super.onPageStarted(view, url, favicon);
}
});
WebSettings settings = getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setBuiltInZoomControls(true);
settings.setPluginsEnabled(true);
settings.setDomStorageEnabled(true);
getSettings().setLoadWithOverviewMode(true);
getSettings().setUseWideViewPort(true);
requestFocus();
requestFocusFromTouch();
loadUrl(url);
}
Example 92
Project: Overchan-Android-master File: FakeBrowser.java View source code |
public static void openFakeBrowser(final Context context, String url) {
dismiss();
if (Uri.parse(url).getScheme() == null)
url = "http://" + url;
final Dialog dialog = new Dialog(context);
WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (context instanceof MainActivity && UrlHandler.getPageModel(url) != null) {
dismiss();
UrlHandler.open(url, (MainActivity) context, true);
} else {
view.loadUrl(url);
}
return true;
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
if (title != null)
dialog.setTitle(title);
}
});
dialog.setContentView(webView);
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.setCanceledOnTouchOutside(false);
dialog.show();
webView.loadUrl(url);
reference = new WeakReference<>(dialog);
}
Example 93
Project: penn-mobile-android-master File: NewsTab.java View source code |
public void loadNews() {
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
if (progress >= 80 && mWebView != null) {
mFlipper.setDisplayedChild(1);
}
}
});
// forces it to open in app
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl(mUrl);
}
Example 94
Project: platform_frameworks_base-master File: LooperAcceleration.java View source code |
private View makeView() {
LinearLayout layout = new LinearLayout(this);
layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
if (INCLUDE_WEBVIEW) {
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient());
wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
return layout;
}
Example 95
Project: Pluto-Android-master File: BlogFragment.java View source code |
private void initUI() {
//去除长按��
webView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return true;
}
});
// 设置WebView属性,能够执行Javascript脚本
WebSettings settings = webView.getSettings();
if (settings != null) {
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
}
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
});
webView.setWebChromeClient(new WebChromeClient());
if (type == 1) {
webView.loadUrl("https://m8en.com");
} else {
webView.loadUrl("http://www.jianshu.com/u/a5016e728b89");
}
}
Example 96
Project: sciencetoolkit-master File: WebViewLoginActivity.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
WebView webview = new WebView(this);
webview.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
setProgress(progress * 100);
}
});
webview.setWebViewClient(new WebViewClient() {
private void checkPage(String url) {
if (url.contains(RemoteApi.WELCOME_PATH)) {
CookieSyncManager.getInstance().sync();
// Get the cookie from cookie jar.
String cookie = CookieManager.getInstance().getCookie(url);
if (cookie == null) {
return;
}
// Cookie is a string like NAME=VALUE [; NAME=VALUE]
String[] pairs = cookie.split(";");
for (int i = 0; i < pairs.length; ++i) {
String[] parts = pairs[i].split("=", 2);
// If token is found, return it to the calling activity.
if (parts.length == 2 && "JSESSIONID".equalsIgnoreCase(parts[0].trim())) {
RemoteApi.get().setSession(parts[1].trim());
finish();
}
}
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
setTitle(url);
checkPage(url);
}
@Override
public void onPageFinished(WebView view, String url) {
checkPage(url);
}
@Override
public void onReceivedError(WebView view, int errorCod, String description, String failingUrl) {
RemoteApi.get().loginActionComplete();
}
});
webview.loadUrl(RemoteApi.PROTOCOL + "://" + RemoteApi.DOMAIN + RemoteApi.PATH + "social/google/login");
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
setContentView(webview);
}
Example 97
Project: shorty-master File: WebBrowserActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.web_browser_view);
(findViewById(R.id.close)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// This tells the download picker to close itself.
WebBrowserActivity.this.setResult(RESULT_OK);
WebBrowserActivity.this.finish();
}
});
mWebView = (WebView) findViewById(R.id.webview);
final WebSettings webSettings = mWebView.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
webSettings.setJavaScriptEnabled(true);
webSettings.setLightTouchEnabled(true);
mPDL = new PuzzleDownloadListener(this);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.endsWith(".puz")) {
// Misconfigured server not reporting download - start it anyway.
mPDL.onDownloadStart(url, webSettings.getUserAgentString(), null, null, 0);
return true;
}
view.loadUrl(url);
mURL.setText(url);
return true;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
WebBrowserActivity.this.setProgress(progress * 100);
}
});
mWebView.setDownloadListener(mPDL);
mIMM = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mURL = (EditText) findViewById(R.id.url);
mURL.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
String url = mURL.getText().toString();
if (!url.contains("://")) {
mURL.setText("http://" + url);
}
mWebView.loadUrl(mURL.getText().toString());
mIMM.hideSoftInputFromWindow(mURL.getWindowToken(), 0);
return true;
}
return false;
}
});
}
Example 98
Project: shuba-master File: BrowserActivity.java View source code |
/**
* �始化视图。
*/
private void initViews() {
pbLoading = (ProgressBar) findViewById(R.id.pb_loading);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webview.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress > 50) {
pbLoading.setVisibility(View.GONE);
}
super.onProgressChanged(view, newProgress);
}
});
webview.loadUrl(url);
}
Example 99
Project: spring-android-samples-master File: AbstractWebViewActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
this.webView = new WebView(this);
setContentView(this.webView);
this.activity = this;
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100) {
activity.setTitle(R.string.app_name);
}
}
});
}
Example 100
Project: spring-for-android-starter-book-master File: AbstractWebViewActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
this.webView = new WebView(this);
setContentView(webView);
this.activity = this;
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100) {
activity.setTitle(R.string.app_name);
}
}
});
}
Example 101
Project: StackX-master File: FullscreenTextActivity.java View source code |
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.code_full_screen);
getActionBar().hide();
CharSequence text = getIntent().getCharSequenceExtra(StringConstants.TEXT);
WebView webView = (WebView) findViewById(R.id.fullScreenText);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadDataWithBaseURL(BASE_URL, CODE_HTML_PREFIX + MarkdownFormatter.escapeHtml(text) + CODE_HTML_SUFFIX, HttpContentTypes.TEXT_HTML, HTTP.UTF_8, null);
}