From 641dea6d84018ae2d9a6e7911ddddc3295976f4f Mon Sep 17 00:00:00 2001 From: Byron Wang Date: Thu, 11 Feb 2016 15:36:21 +0800 Subject: [PATCH] Show dialog on UI thread to avoid crash --- .../reactnativedialogs/modules/DialogAndroid.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java index 35119bc..3b07e05 100644 --- a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java +++ b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java @@ -284,11 +284,14 @@ public class DialogAndroid extends ReactContextBaseJavaModule { } }); } - - if(mDialog != null) - mDialog.dismiss(); - mDialog = mBuilder.build(); - mDialog.show(); + mActivity.runOnUiThread(new Runnable() { + public void run() { + if(mDialog != null) + mDialog.dismiss(); + mDialog = mBuilder.build(); + mDialog.show(); + } + }); } @ReactMethod