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

[Android] Fix crash in receiver. #2840

Merged
merged 1 commit into from
Sep 4, 2019

Conversation

YorkShen
Copy link
Contributor

Brief Description of the PR

Fix the following crash

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)

Checklist

  • Demo:
  • Documentation:

```
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)
```
@weex-bot
Copy link

Warnings
⚠️ No Changelog changes! - Can you add a Changelog? To do so,append your changes to the changelog.md
⚠️ Current pr not bind the milestone
⚠️ If your PR is about fixing a bug excluding crash the code,you should add the demo link in the PR description. Demo link: http://dotwe.org/vue
⚠️ If you update the code, maybe you should update the documentation and add the documentation link in the PR description. here is the guide about how to contribute documentation: https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#contribute-code-or-document
Messages
📖 danger test finished.

Generated by 🚫 dangerJS against 6f3c67e

@YorkShen YorkShen added this to the Weex 0.27 milestone Aug 20, 2019
Copy link
Contributor

@lucky-chen lucky-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if (mGlobalEventReceiver != null) {
getContext().unregisterReceiver(mGlobalEventReceiver);
mGlobalEventReceiver = null;
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add bool val onActivityCreate. then

onActivityCreate(){
 hasRegister = true;
}

and

if(hasRegister){
   getContext().unregisterReceiver(mGlobalEventReceiver);

}

@lucky-chen lucky-chen merged commit 7543ea7 into apache:master Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants