且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在WebView应用程序中打开深层链接

更新时间:2023-11-22 21:13:58

启动活动后,在 onNewIntent(Intent intent)方法中,从 intent 获取数据(应该是点击的网址-深度链接),其类型为 uri ,然后将该网址加载到您已实现的网络视图中.

When the activity is launched, in the onNewIntent(Intent intent) method, get data from intent (it is supposed to be the url clicked - deep link) which has the type uri, and then load that url in the web view that you've implemented.

类似下面的代码:

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Uri data = intent.getData();
        
    webView.loadUrl(data.toString());
}