0
votes

I am using Otto to send events from IntentService to my Activity. IntentService is Downloading files from server and send progress to Activity this is working with otto very well. -

I have done so far

  1. registered otto in OnResume

    BusStation.getBus().unregister(this);
    
  2. created function to receive events

@Subscribe public void receiveProgress(Message message){ Log.i("Downloader",message.getMessage()+""); }

  1. unregister bus in OnPause

    BusStation.getBus().unregister(this);

  2. I have Button on which click DownloadService is started and this service sends download progress to receiveProgress function.

but when I close my app and Restart app and then if DownloadSerice still downloading file it never send Download progress event on receiveProgress so how to relink this.

1

1 Answers

0
votes

I assume that BusStation.getBus() returns a singleton. However, when you restart the app the singleton has to be created again and therefore it is not the same instance anymore.

You can solve this problem by using LocalBroadcastManager instead:

https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html