0

hey I'm new on android studio im making webview app. my app working perfectly on same domain but when i open other domain links then not opening. App Error Screenshot

ex. example.com is my main webview app URL. website lode and work perfectly on this domain but when i want to open other domain link like secondexample.com or other domain sites then website not opening. here is my code please help I'm stuck on this i reserched about this but no solution find.

public class MainActivity extends Activity {
    private WebView mywebView;

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mywebView = (WebView) findViewById(R.id.webview);
        WebSettings webSettings = mywebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mywebView.loadUrl("https://nishaboutique.online/");

        mywebView.setWebViewClient((new WebViewClient()));

        // Improve performance

        mywebView.getSettings().setAllowFileAccess(true);
        mywebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
        mywebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        mywebView.getSettings().setAppCacheEnabled(true);
        mywebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        webSettings.setDomStorageEnabled(true);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        webSettings.setUseWideViewPort(true);
        webSettings.setSavePassword(true);
        webSettings.setSaveFormData(true);
        webSettings.setEnableSmoothTransition(true);
    }
  • look at this link: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – saeedata Dec 10 '20 at 13:14

1 Answers1

0

Use this link. It shows a similar error. The solution is to add a network_security_config.xml file and update your manifest file.

newtwork_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
        <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">api.example.com(to be adjusted)</domain>
        </domain-config>
</network-security-config>

If this doesn't work, consider changing the url from "http" to "https".

SatvikVejendla
  • 424
  • 5
  • 14
  • Not working on whatsapp chat link and google maps link. Same error giving. – Ayaz Syyed Dec 10 '20 at 14:36
  • It could be because you might need to login for those websites. – SatvikVejendla Dec 10 '20 at 14:38
  • i convertet my website into mobile app using webview feature of android studio. in my website some links like whatsapp chat or google map direction link opens in new tap and connects to there apps. but in my webview app this links not working showing error "ERR_UNKNOWN_URL_SCHEME" how to fix that. so this links open in external browsers or on there particular apps. – Ayaz Syyed Dec 11 '20 at 05:35