Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] Fix crash in receiver. (#2840)
Browse files Browse the repository at this point in the history
```
java.lang.IllegalArgumentException: Receiver not registered: com.taobao.weex.WXGlobalEventReceiver@df9ef3f
	at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1095)
	at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1500)
	at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:608)
	at com.taobao.weex.WXSDKInstance.destroy(WXSDKInstance.java:1832)
	at com.taobao.weex.WXSDKInstance.onActivityDestroy(WXSDKInstance.java:1457)
```
  • Loading branch information
YorkShen authored and lucky-chen committed Sep 4, 2019
1 parent 440ae80 commit 7543ea7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -1837,10 +1837,15 @@ public synchronized void destroy() {
WXSDKManager.getInstance().destroyInstance(mInstanceId);
}

if (mGlobalEventReceiver != null) {
getContext().unregisterReceiver(mGlobalEventReceiver);
mGlobalEventReceiver = null;
try {
if (mGlobalEventReceiver != null) {
getContext().unregisterReceiver(mGlobalEventReceiver);
mGlobalEventReceiver = null;
}
}catch (IllegalArgumentException e){
WXLogUtils.w(WXLogUtils.getStackTrace(e));
}

if (mRootComp != null) {
mRootComp.destroy();
mRootComp = null;
Expand Down

0 comments on commit 7543ea7

Please sign in to comment.