BroadcastReceiver within a Service not receiving broadcasts Android

前端 未结 2 1820
陌清茗
陌清茗 2020-12-21 01:02

I\'ve got this app, in which users update certain variables in an Activity, and this Activity passes the new variables to a IntentService using a BroadcastReceiver. However,

2条回答
  •  别那么骄傲
    2020-12-21 01:25

    this Activity passes the new variables to a IntentService using a BroadcastReceiver.

    That makes no sense. Use startService() to send a command to an IntentService. And an IntentService should not have a BroadcastReceiver, because the IntentService will be destroyed as soon as onHandleIntent() completes and therefore will never receive the broadcast.

    I've tried using LocalBroadcastManager in this project since the broadcasts are all local but eclipse doesn't seem to be able to import the compatibility class.

    :: shrug ::

    Here is a sample project with Eclipse project files that uses LocalBroadcastManager. I encountered no particular Eclipse issues when creating the project.

提交回复
热议问题