-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix broadcast receiver #3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix broadcast receiver #3168
Conversation
Interesting that we got two PR the same day for that issue, refs #3167, is it a recent regression? |
I have to check this version. I will know you. But Mine one #3167 is working fine I have tested on Android 14 . No crash on_pause on_reaume of java thread on Android |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions to add.
self.handlerthread.start() | ||
|
||
if self._is_registered: | ||
print("[BroadcastReceiver] Already registered.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better with a logger instead of print.
self.context.unregisterReceiver(self.receiver) | ||
self._is_registered = False | ||
except Exception as e: | ||
print("[BroadcastReceiver] unregisterReceiver failed:", e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better with a logger instead of print.
Handler = autoclass('android.os.Handler') | ||
|
||
if hasattr(self, 'handlerthread') and self.handlerthread.isAlive(): | ||
print("HandlerThread already running, skipping start") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better with a logger instead of print.
logger = logging.getLogger("BroadcastReceiver")
logger.setLevel(logging.DEBUG) This. |
Can you update the PR with these changes? |
Yepp. |
Fix BroadcastReceiver
jnius.jnius.JavaException: JVM exception occurred: java.lang.IllegalThreadStateException
during runtime.