ActivityMessenger | ActivityMessenger,借助Kotlin特性,简化Activity之间传参和回调的逻辑代码。
kandi X-RAY | ActivityMessenger Summary
kandi X-RAY | ActivityMessenger Summary
ActivityMessenger,借助Kotlin特性,简化Activity之间传参和回调的逻辑代码。
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ActivityMessenger
ActivityMessenger Key Features
ActivityMessenger Examples and Code Snippets
Community Discussions
Trending Discussions on ActivityMessenger
QUESTION
A common approach for checking if you have bounded to a service in Android is keeping a boolean parameter such as mBound
in your binding steps as described in Android developers guide. I noticed a problem in this Android reference tutorial and I think this approach is somehow a bad practice. Here is the code from Bound Services:
Here is a code block with language code as hint:
...ANSWER
Answered 2018-Feb-28 at 18:44I haven't tried this in practice, but it seems reasonable to set mBound = true
already when calling bindService
instead of in the callback. Actually, the documentation says that you should call unbindService
even if bindService
returned false
(meaning you would never get any onServiceConnected
call and mBound
would never be true):
Note: If the method returns false, your client does not have a valid connection to the service. However, your client should still call unbindService(); otherwise, your client will keep the service from shutting down when it is idle.
With this in mind it's clear that only setting mBound = true
in onServiceConnected
is not sufficient (or at least recommended). I would suspect that calling unbindService
when not previously bound is a no-op, but that might need some confirmation. If so, setting mBound = true
when calling bindService
seems like a good approach.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ActivityMessenger
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page