I'm trying to implement deep linking in android app.
When I click the deep linking of custom url (xxxx://repost?id=12) on Android browser like Chrome, my app opens up and works very well.
Problem is, in the app, there's a webView widget, and I want to the deep-linking work there too.
Currently, it's showing Can't connect to the server
error.
Thanks in advance.
Android Studio makes it very easy to test deep links. Click Run > Edit Configurations to edit the configuration of the project. Open the General tab at the top and enter the URI in the Deep Link field in the Launch Options section.
Select Open deep link URL in a browser option. Click Next. For Android, select Open the deep link in your Android app. Then select your app from the dropdown, in this case the com.
Deep linking, in simplest terms, is the ability to link directly to content in your app. Instead of simply launching the app and leaving users at the home screen, tapping on a deep link brings users to a specific screen within your app. Think product pages, profiles, new content, or shopping carts.
To use the tool, log in to your Adjust dashboard and open the Menu, where you'll see the 'Deeplink Generator' as an option. Click to open, and you'll find a page to input the information required to create your deep link. Then simply copy and paste into whichever campaign you've set up.
This is the problem with android web view as this treats everything as URL but other browser like chrome on mobile intercepts the scheme and OS will do the rest to open the corresponding app. To implement this you need to modify your web view shouldOverrideUrlLoading functions as follows:
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { LogUtils.info(TAG, "shouldOverrideUrlLoading: " + url); Intent intent; if (url.contains(AppConstants.DEEP_LINK_PREFIX)) { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); return true; } }
In above code replace AppConstants.DEEP_LINK_PREFIX with your url scheme eg.
android-app://your package
Hope this helps!!
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