Messenger to Remote Service Causing Memory Leak

后端 未结 2 866
再見小時候
再見小時候 2021-01-03 14:39

I have an application that communicates with a Service in a remote process using the Messenger interface. Here is the basic architecture of how th

2条回答
  •  悲哀的现实
    2021-01-03 15:03

    I am not sure if this is the best way since, even if Activity is in the background you will get the message from Service.

    I think you should bind to the service and register a messenger to the service as soon as Service is connected. And then unregister the messenger when you disconnect.

    Check ExportVcardActivity in AOSP. It is following something along these lines.

提交回复
热议问题