Skip to content

Instantly share code, notes, and snippets.

@yamanetoshi
Created July 27, 2015 06:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamanetoshi/ad7561a572e8bf8104d7 to your computer and use it in GitHub Desktop.
Save yamanetoshi/ad7561a572e8bf8104d7 to your computer and use it in GitHub Desktop.
XWalkView Example
mWebView.setResourceClient(new XWalkResourceClient(mWebView) {
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
WebResourceResponse ret = null;
try {
URL tmpUrl = new URL(url);
mConn = (HttpURLConnection)tmpUrl.openConnection();
mConn.addRequestProperty("Authorization", authHeader);
mConn.addRequestProperty(getString(R.string.app_version_header_key), ((MyApplication)getApplication()).getVersioName());
mConn.connect();
Log.d(TAG, "contentType: " + mConn.getContentType());
Log.d(TAG, "contentEncoding : " + mConn.getContentEncoding());
ret = new WebResourceResponse("text/html",
"UTF-8",
mConn.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
return ret;
}
@Override
public void onLoadStarted(XWalkView view, String url) {
super.onLoadStarted(view, url);
}
@Override
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
mConn.disconnect();
}
@Override
public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
Log.d(TAG, "shoudOverrideUrlLoading url : " + url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment