Created
July 27, 2015 06:55
-
-
Save yamanetoshi/ad7561a572e8bf8104d7 to your computer and use it in GitHub Desktop.
XWalkView Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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