Skip to content

Commit 874e3e1

Browse files
Merge remote-tracking branch 'origin/master' into SDK-337-in-app-close-button-position
2 parents 78ec607 + 6662d7d commit 874e3e1

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import android.app.Activity;
44
import android.app.Dialog;
5+
import android.content.Context;
56
import android.content.DialogInterface;
7+
import android.content.res.Resources;
68
import android.graphics.Color;
79
import android.graphics.Rect;
810
import android.graphics.drawable.ColorDrawable;
@@ -192,9 +194,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
192194
applyWindowGravity(getDialog().getWindow(), "onCreateView");
193195
}
194196

195-
webView = new IterableWebView(getContext());
197+
webView = createWebViewSafely(getContext());
198+
if (webView == null) {
199+
dismissAllowingStateLoss();
200+
return null;
201+
}
196202
webView.setId(R.id.webView);
197-
198203
webView.createWithHtml(this, htmlString);
199204

200205
if (orientationListener == null) {
@@ -314,7 +319,9 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
314319
*/
315320
@Override
316321
public void onStop() {
317-
orientationListener.disable();
322+
if (orientationListener != null) {
323+
orientationListener.disable();
324+
}
318325

319326
super.onStop();
320327
}
@@ -838,6 +845,18 @@ InAppLayout getInAppLayout(Rect padding) {
838845
return InAppLayout.CENTER;
839846
}
840847
}
848+
849+
private IterableWebView createWebViewSafely(Context context) {
850+
try {
851+
return new IterableWebView(context);
852+
} catch (Resources.NotFoundException e) {
853+
IterableLogger.e(TAG, "Failed to create WebView - system WebView resource issue", e);
854+
return null;
855+
} catch (RuntimeException e) {
856+
IterableLogger.e(TAG, "Failed to create WebView - unexpected error", e);
857+
return null;
858+
}
859+
}
841860
}
842861

843862
enum InAppLayout {

0 commit comments

Comments
 (0)