Unverified Commit ba126ae1 authored by JinHao Chen's avatar JinHao Chen Committed by GitHub

Catch right exception

WebSettings.getDefaultUserAgent throw `RunTimeException` instead of `PackageManager.NameNotFoundException`
parent c1e93065
...@@ -172,7 +172,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -172,7 +172,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try { try {
constants.put("userAgent", WebSettings.getDefaultUserAgent(this.reactContext)); constants.put("userAgent", WebSettings.getDefaultUserAgent(this.reactContext));
} catch (PackageManager.NameNotFoundException e) { } catch (RuntimeException e) {
constants.put("userAgent", System.getProperty("http.agent")); constants.put("userAgent", System.getProperty("http.agent"));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment