What is the err_unknown_url_system Android WebView error?

The err_unknown_url_plan error commonly comes up in the time of Android WebView app advancement once a developer has liked links to have mailto://, whatsapp://, or any type of other intent that’s not the basic http:// or https://. Specific URL coding needs to be included to take care of these distinction URL schemes to proccasion this error.

You are watching: Net err_unknown_url_scheme

*

What are Native Apps? How are they pertained to the err_unknown_url_plan error?

Native apps live in the Google Play Store or App Store. They are totally developed applications that are installed straight onto the mobile device. Native apps will certainly preserve most of their usability even as soon as not linked to the internet or mobile netfunctions. These differ from web apps, which are ssuggest websites. Web applications are much easier to build but don’t have access to any mechanism functions prefer GENERAL PRACTITIONERS.

As a developer you may want to build a indigenous application yet still carry out access to web content. This is done using WebView. WebView is a distinct class that permits web content to be presented within your aboriginal application. For example, if you have the native Facebook app on your phone and click an exterior attach, the webpage will certainly fill within the app. You have the right to navigate around on the loaded webpage, access various other parts of the webpage, shop, and interact. The embedded browser will certainly not have an attend to bar for your user to search via. This offers the developer a method to have actually both the benefits of a web application and also a indigenous app.

WebView is set to take care of certain URL schemes. If you try to usage a distinct URL system exterior the conventional https:// and http://, WebView can throw the err_unknown_url_system error. A few of the non-conventional URL schemes that WebView isn’t set to identify are:

mailto://whatsup://file://telnet://intent://market://app://
*

3 means to resolve the err_unknown_url_plan error

To resolve this error, you have the right to go among 2 routes: either disable those schemes and only build your app making use of http:// and https:// schemes, or you can modify your code to have the ability to manage these specific URL schemes. The first alternative is not an absolute solution but have the right to resolve the problem in some use cases. The second solution mirrors examples of exactly how to include new intents for URL schemes, and also the third solution entails disabling any type of non-traditional URL schemes.

1. Open In New Window

A quick and easy stopgap solution is modifying your URL href code. By adding target=”_blank” you are able to fix the difficulty in a roundaround means. Now including this snippet of code deserve to have actually an undesirable development effect bereason this attach will currently open in a new home window.

Advancement finest practice is to prevent opening extra internet browser home windows. This is because a new web browser can bother or confuse your user. By removing the ‘back’ button, individuals uncover it even more hard to navigate and also obtain ago to their previous page in your application. The conventional is target=”_self”, which opens the attach in the same browser page.

Below is an example of URL href code through target=”_blank” added in:

Contact Me Or:

Email Me

2. Add New Intent to Load in External App

In Android development, intents are provided to tell Android what you desire the app to execute, essentially allowing you to contact a specific activity or component. Some plan errors deserve to be solved by including an intent to fill in an exterior application. For instance, loading mailto:// in an exterior application need to cause the email link to open in your default email application. Anvarious other instance is maps:// which need to open in your default maps application.

In the code snippet listed below, you will certainly be using an IF statement to take care of this. Any URL that starts with http:// or https:// is ignored and opened up as usual. Otherwise, if the URL entails a distinct plan such as:

tel://sms://mailto://geo://maps://

then a brand-new intent is included to load the action in an outside application. If the activity cannot be effectively began bereason no associated exterior application exists on that system, an error will certainly show up to the user.


Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) Anvarious other code snippet is had below to show that you can tackle this difficulty in a range of ways. This technique overrides URL loading prefer checked out over and have to open up a associated application to bring out the protocol. If the connected application, in this instance Whatsapp is not installed, a message is displayed for your user. This message is referred to as a toast message and also provides the user an concept on what went wrong and how to solve it. The toast message for this scheme was ‘Whatsapplication has not been installed’.


Overridepublic boolean shouldOverrideUrlLoading(WebView see, String url) check out.loadUrl(url); if (url.startsWith("whatsapp://")) webcheck out.stopLoading(); try Intent whatsappIntent = brand-new Intent(Intent.ACTION_SEND); whatsappIntent.setType("text/plain"); whatsappIntent.setPackage("com.whatsapp"); whatsappIntent.putExtra(Intent.EXTRA_TEXT, websee.getUrl() + " - Shared from webcheck out "); startActivity(whatsappIntent); capture (android.content.ActivityNotFoundException ex) String MakeShortText = "Whatsapplication has not been installed"; Toast.makeText(WebactivityTab1.this, MakeShortText, Toast.LENGTH_SHORT).show(); ;;

3. Disable any kind of non-conventional URL schemes

By disabling URL schemes various other than the standard https:// and also http:// you are bypassing this trouble entirely. You won’t be able to usage any kind of tradition schemes prefer the ones noted earlier in the short article.

If your app has actually among these schemes or a user somehow navigateways to a attach making use of these schemes, a toast message will certainly appear. The message “Error: Unknown link type” will certainly tell the user they can’t proceed. Below is an example of this method:


Overridepublic boolean shouldOverrideUrlLoading(WebView watch, String url)

WebView Has Great Benefits, But Some Creative Coding Is Needed

Android WebView really offers the best of both civilizations for Android developers, but creative workarounds are required for some cases. By using WebView to display an installed browser within your native app, you get all the benefits of both the aboriginal app and a internet application. You will certainly be able to usage the indigenous device APIs in your web code which is typically constrained.

If you are emerging an application and desire to include one-of-a-kind URLs, outside of http:// and https:// you will certainly have to include some intents or loss earlier URLs, otherwise your our users will certainly experience the error “err_unknown_url_scheme”. When a URL choose mailto:// or maps:// is dubbed, your code demands to open up an associated outside app that deserve to finish that activity. Otherwise you have the right to disable these other URLs and collection a certain error message to any kind of individuals that stumbles upon a connect via among these URL schemes.

See more: Ios 9 Beta Emojis : How To Get Them, Get 72 New Unicode 9


Leave a Comment Cancel reply

Comment

NameEmail

Save my name, email, and also website in this browser for the next time I comment.