Whenever I open the webview and click on the Facebook share button, it works perfectly. However, after the share is completed, it leads me to a blank page.
Sometimes, instead of a blank page, it actually shows the original page. But most of the time, it's a blank page.
I really want to ensure that the page with the share button is always displayed.
Below is the code snippet:
//in onCreate.
String Url = //my url//;
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setDomStorageEnabled(true);
view.getSettings().setSupportZoom(true);
view.getSettings().setBuiltInZoomControls(true);
view.getSettings().setUseWideViewPort(true);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setAppCacheEnabled(true);
view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
view.getSettings().setAllowFileAccess(true);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().setAcceptThirdPartyCookies(view, true);
}
view.loadUrl(Url);
view.setWebViewClient(new myWebViewClient());
view.setWebChromeClient(new ChromeClient());
//
private class ChromeClient extends WebChromeClient{
@Override
public void onProgressChanged(WebView view, int newProgress) {
MainActivity.this.setProgress(newProgress*1000);
}
public void onCloseWindow(WebView window){
super.onCloseWindow(window);
}
And here is the JavaScript code snippet:
function fn_facebook_share() {
var url = //my url//;
var title = "${VideoModelDetail.title}";
var user_nm= "${VideoModelDetail.user_nm}";
var univ="${VideoModelDetail.univ_cd_nm}";
FB.ui({
method: 'feed',
link: url,
name:title,
caption:univ+" | "+user_nm,
description:'text',
}, function(response){});
}