简体   繁体   English

如何为所有域设置 WebView 权限,如谷歌 map 链接 whatsapp 聊天链接

[英]How to set WebView permission for all domain like google map link whatsapp chat link

hey I'm new on android studio im making webview app.嘿,我是 android 工作室的新手,我正在制作 webview 应用程序。 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. example.com是我的主要 webview 应用程序 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.网站在此域上完美运行,但是当我想打开其他域链接(如secondexample.com或其他域站点)时,网站无法打开。 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);
    }

Use this link .使用此链接 It shows a similar error.它显示了类似的错误。 The solution is to add a network_security_config.xml file and update your manifest file.解决方案是添加 network_security_config.xml 文件并更新您的清单文件。

newtwork_security_config.xml 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".如果这不起作用,请考虑将 url 从“http”更改为“https”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 WhatsApp 点击聊天链接在手机上找不到 WhatsApp Messenger - How to fix WhatsApp Click to chat link not finding WhatsApp messenger on phones 如何通过C#/ Xamarin中webview的链接调用whatsapp? - How to call whatsapp through a link from webview in C#/Xamarin? 如何创建类似消息堆栈的 whatsapp(首先是聊天屏幕) - How to create whatsapp like message stack(First all chat screen) 加载链接后如何设置Webview区域? - How to set webview area upon loading a link? 如何从资源设置Webview链接颜色 - How to set Webview link color from resource 如何使用所有子文件创建自己的地图文件,如链接节点,名称,索引等,如以下链接 - how to create own map file with all sub files ,like link node, names, index and etc like following link 如何像 WhatsApp 聊天一样创建回收者视图 - How to create recycler view like WhatsApp chat 如何制作像WhatsApp Chat活动一样的RecylerView? - How to make a RecylerView like WhatsApp Chat activity? 聊天布局像whatsapp - Chat layout like whatsapp Google电子表格创建了一个新的工作表,所有用户都拥有链接的权限 - Google spreadsheet create a new sheet with permission for all users have link
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM