From a2aab625f3da4f24c42ed205150886ce867b4835 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 1 Oct 2016 11:37:04 -0700 Subject: [PATCH] Fix webview crash when trying to display local html files Summary: When using webview on android and trying to link to an html file located on device (using `file://`), the application would crash with an error specifying that nothing handles the fired intent. This is due to [`33a1f28`](https://github.com/facebook/react-native/commit/33a1f28654e24a47d80f6ffc75072d0158085a09) which attempts to intercept all non `http(s)` links. This is a simple fix so hopefully it can make it into the next stable release. Closes https://github.com/facebook/react-native/pull/9668 Differential Revision: D3956485 fbshipit-source-id: 5a752abc21802a44e3a26e88669ccb6852076992 --- .../com/facebook/react/views/webview/ReactWebViewManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java index efe7bd7d2..6e1509185 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java @@ -118,7 +118,8 @@ public class ReactWebViewManager extends SimpleViewManager { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (url.startsWith("http://") || url.startsWith("https://")) { + if (url.startsWith("http://") || url.startsWith("https://") || + url.startsWith("file://")) { return false; } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));