I'm already active JavaScript for a given WebView, and opens new link inside the WebView, not in the Browser. This Is Main Activity
package com.Afrogfx.pronouns;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
@SuppressLint("SetJavaScriptEnabled")
public class MainActivityPronouns extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_pronouns);
WebView wvHtml = (WebView) findViewById(R.id.webview);
wvHtml.getSettings().setBuiltInZoomControls(true);
wvHtml.getSettings().setJavaScriptEnabled(true);
wvHtml.loadUrl("http://afrogfx.com/appcatcategories.php?catid=13&parentid=11");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main_activity_pronouns, menu);
return true;
}
}
how can i handel my code to open all link in site inside the WebView (App) , not in the Browser & ( don't show to user Open in browser).
Tap Android System WebView and then tap Disable.
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
Android System WebView lets applications display browser windows in an app instead of transporting the user to another browser. Android developers use WebView when they want to display webpages in a Google app or other application.
For that just create the subclass that is extending webclient and use the method of that class onPageFinished(WebView c,String url) and
public boolean shouldOverrideUrlLoading(final WebView view, final String url)
here is the code-
myWebView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
//view.loadUrl(url);
System.out.println("hello");
return false;
}
});
myWebView.loadUrl(url);
In case you use Kotlin:
webView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
return false
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With