I have my activity that loads webview as below
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set layout
setContentView(R.layout.activity_webview);
// get loading view
loadingView = findViewById(R.id.loadingView);
loadingView.setVisibility(View.VISIBLE);
// extract extras from intent
Intent intent = getIntent();
// get and setup WebView
webview = (WebView) findViewById(R.id.webView);
// implement progress bar
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
loadingView.setVisibility(View.GONE);
// if no title was passed in with the intent use the page's title
if (TextUtils.isEmpty(title)) {
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(view.getTitle());
}
}
@SuppressWarnings("deprecation")
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
showErrorAndFinish();
}
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
// Redirect to deprecated method, so you can use it in all SDK versions
onReceivedError(view, error.getErrorCode(), error.getDescription().toString(), request.getUrl().toString());
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
return super.shouldInterceptRequest(view, request);
}
});
// load the url
webView.loadUrl(url);
}
However, I need to look at response of the Url that I load and call to another API URL based on the response.
I have looked so far for thisURL Loading QUestion but not much helpful under 5.0. Any suggestions on how should I approach? Should I just use Retrofit in shouldOverrideUrlLoading()
method?
Also, I cannot modify both the URL's that I am loading .
I would appreciate the response