Skip to content

Commit 08547b7

Browse files
author
sunny.luo
committed
use reflect
1 parent d355b37 commit 08547b7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,21 @@ public void run() {
144144
return;
145145
}
146146
try {
147-
final ReactDelegate reactDelegate = ((ReactActivity) currentActivity).getReactDelegate();
148-
reactDelegate.reload();
147+
// Try to get getReactDelegate method using reflection
148+
java.lang.reflect.Method getReactDelegateMethod =
149+
ReactActivity.class.getMethod("getReactDelegate");
150+
if (getReactDelegateMethod != null) {
151+
ReactDelegate reactDelegate = (ReactDelegate)
152+
getReactDelegateMethod.invoke(currentActivity);
153+
reactDelegate.reload();
154+
} else {
155+
currentActivity.runOnUiThread(new Runnable() {
156+
@Override
157+
public void run() {
158+
currentActivity.recreate();
159+
}
160+
});
161+
}
149162
} catch (Throwable e) {
150163
currentActivity.runOnUiThread(new Runnable() {
151164
@Override

0 commit comments

Comments
 (0)