Issue
My onPageFinished is not firing. At the @OverRide the warning "Method does not overwrite the Method in the superclass".
I have pasted the relevant code. Help willbe deeply appreciated.
public class MainActivity extends Activity {
private WebView mWebView;
private String typeOrientation = "landscape";
@Override
protected void onCreate(Bundle savedInstanceState) {
if (typeOrientation.equals("landscape"))
{ setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
/* mWebView.setWebViewClient(new WebViewClient());*/
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
void onPageFinished(WebView view, String url) {
Toast.makeText(getApplicationContext(), "Logout", Toast.LENGTH_LONG).show();
//hide loading image
findViewById(R.id.imageLoading1).setVisibility(View.GONE);
//show webview
findViewById(R.id.activity_main_webview).setVisibility(View.VISIBLE);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mWebView.setWebContentsDebuggingEnabled(true);
}
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(this, "Android");
mWebView.loadUrl("file:///android_asset/index.html");
}
Solution
onPageFinished is not part of WebChromeClient, therefore you can't override it. It belongs to WebViewClient. You can set an instance of it calling setWebViewClient. You can read more here. Please be also aware that the correct signature is
@Override
public void onPageFinished(WebView view, String url) {
with public as access specifier.
Answered By - Blackbelt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.