use of android.webkit.WebViewClient in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
browser = (WebView) findViewById(R.id.browser);
browser.getSettings().setJavaScriptEnabled(true);
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return (true);
}
});
visit(getIntent());
}
use of android.webkit.WebViewClient in project cw-omnibus by commonsguy.
the class BrowserDemo4 method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
browser = (WebView) findViewById(R.id.webkit);
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return (true);
}
});
browser.loadUrl("http://commonsware.com");
}
use of android.webkit.WebViewClient in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" })
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mgr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
light = mgr.getDefaultSensor(Sensor.TYPE_LIGHT);
wv = (WebView) findViewById(R.id.webkit);
wv.getSettings().setJavaScriptEnabled(true);
wv.addJavascriptInterface(jsInterface, "LIGHT_SENSOR");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
initPort();
}
});
}
wv.loadUrl(URL);
}
use of android.webkit.WebViewClient in project materialistic by hidroh.
the class WebFragmentTest method testAdBlocker.
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Test
public void testAdBlocker() {
WebView webView = (WebView) activity.findViewById(R.id.web_view);
WebViewClient client = shadowOf(webView).getWebViewClient();
assertNull(client.shouldInterceptRequest(webView, "http://google.com"));
assertNull(client.shouldInterceptRequest(webView, "http://google.com"));
assertNotNull(client.shouldInterceptRequest(webView, "http://page2.g.doubleclick.net"));
assertNotNull(client.shouldInterceptRequest(webView, "http://page2.g.doubleclick.net"));
}
use of android.webkit.WebViewClient in project remusic by aa112901.
the class TopFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_top, container, false);
webView = (WebView) view.findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36");
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 根据传入的参数再去加载新的网页
view.loadUrl(url);
// 表示当前WebView可以处理打开新网页的请求,不用借助系统浏览器
return true;
}
});
webView.loadUrl("http://music.163.com/#/discover/toplist?id=19723756");
return view;
}
Aggregations