How To Set That All External Links Open In Default Web Browser With Android Webview

58 views Asked by At

Here is code made by my self for android webview.

public class MainActivity extends AppCompatActivity {
    public static int UPDATE_CODE = 22;
    AppUpdateManager appUpdateManager;

    String websiteURL = "https://linkshortify.com/member/dashboard";
    private WebView webview;
    SwipeRefreshLayout mySwipeRefreshLayout;
    private int requestCode;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        inAppUp(
        );
        if (!CheckNetwork.isInternetAvailable(this))
        {
            setContentView(R.layout.activity_main);
            new AlertDialog.Builder(this)
                    .setTitle("Oops ! No Internet Connection")
                    .setMessage("Please Check You're Mobile Data Or Wifi Connection")
                    .setPositiveButton("Exit", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();
                        }
                    })
                    .show();

        } else {
            webview = findViewById(R.id.webView);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.getSettings().setDomStorageEnabled(true);
            webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
            webview.loadUrl(websiteURL);
            webview.setWebViewClient(new WebViewClientDemo());
            webview.setWebChromeClient(new WebChromeClient());
            webview.getSettings().setUserAgentString("LinkShortify");
        } 

i have almost tried all available codes and suggestions to implant this feature but they are not working or i am not good to understand.(including stackoverflow)

So I am first checking internet connection and then running basic webview. but i want to add function that opne all external links into defult web browser. also help me and tell the place where to implant it.

need solution to add function without irruption and also app supports android 6 to android 13 devices

0

There are 0 answers