Android Webview net::ERR_UNKNOWN_URL_SCHEME Error To Play Store
This error is appeared because the WebView can’t recognize the special URL Scheme,
for example, the WebView will usually recognize http and https, anything other than these, for example – intent://, market://, app://, mail:// , whatsapp:// etc will not be recognized by WebView unless we add a handler to handle these url schemes, or by disabling these schemes and only load http and https schemes.
The Code to Fix err_unknown_url_scheme intent://
webview.setWebViewClient(new WebViewClient() {
String currentUrl;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
currentUrl = url;
if (url.startsWith("http") || url.startsWith("https")) {
return false;
}
if (url.startsWith("intent")) {
try {
Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
String fallbackUrl = intent.getStringExtra("browser_fallback_url");
if (fallbackUrl != null) {
webview.loadUrl(fallbackUrl);
return true;
}}
catch (URISyntaxException e) {
//not an intent uri
}
return true;//do nothing in other cases
}
fix net::err_unknown_url_scheme whatsapp link on flutter webview
First, add url_launcher, then I use this code to launch whatsapp on flutter webview and works.
WebView(
initialUrl: getUrl(_url),
javascriptMode: JavascriptMode.unrestricted,
navigationDelegate: (NavigationRequest request) async {
if (request.url
.startsWith('https://api.whatsapp.com/send?phone')) {
print('blocking navigation to $request}');
List<String> urlSplitted = request.url.split("&text=");
String phone = "0123456789";
String message =
urlSplitted.last.toString().replaceAll("%20", " ");
await _launchURL(
"https://wa.me/$phone/?text=${Uri.parse(message)}");
return NavigationDecision.prevent;
}
print('allowing navigation to $request');
return NavigationDecision.navigate;
},
)
_launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
Related Topics
Arrayadapter in Android to Create Simple Listview
How to Add a Badge to an Application Icon in Android
Get All User Friends Using Facebook Graph API - Android
How to Create a User-Defined Function in SQLite
Listview with Clickable/Editable Widget
How to Get File in Assets from Android Ndk
Adding Button Action in Custom Notification
How to Get String from Different Locales in Android
Get the Id of a Drawable in Imageview
How to Get Current Activity's Layout and Views via Adb
Get Database File in /Data/Data on Rooted Device
Android Command Line Tools Sdkmanager Always Shows: Warning: Could Not Create Settings
Create a Ninepatch/Ninepatchdrawable in Runtime
Manifest Merger Fails for Appcomponentfactory
Android SQLite Db When to Close
Didn't Find Class "Com.Google.Firebase.Provider.Firebaseinitprovider"