Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From inspecting the return flag specified in your <code>onStartCommand</code> I can see you have specified <code>START_REDELIVER_INTENT</code>. The Javadoc for this type of return flag states;</p> <blockquote> <p>if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)), then it will be scheduled for a restart and the last delivered Intent re-delivered to it again via onStartCommand(Intent, int, int)</p> </blockquote> <p>From this explanation it is apparent that your service is being killed. The reason for this is unclear but ensuring Services (and their child threads) remain 'alive' is something I have grappled with before. In our application we found that phone sleeps were particularly destructive. We 'hacked' (?) around these nuances by giving the service a Wake-Lock and WiFi-Lock to ensure (a) the Service wasn't mothballed on sleep and (b) the system kept a wifi lock (i.e. didn't drop the active wifi connection) whilst we had work to do in our child threads. Please look into your Service's behaviour under a sleep environment after we get this sorted. Nonetheless, this flag seems to explain the apparent restarting of your service and the download re-attempt.</p> <p>From briefly reviewing your code I see that you are communicating with your service from your thread. An <code>IntentService</code> maybe applicable in this scenario as Ranjith points out. However, the child thread cannot communicate with the Service which spun off the worker thread. The reason for this is that the hosting service is almost immediately killed after spinning off the worker thread since the service's job is done with all remaining work being completed asynchronously. This could explain why this didn't work for you.</p> <p>To move forward with this I would attempt one of the following;</p> <ol> <li>Use an <code>IntentService</code> and move all notification code down into the thread and sever all AsyncTask-Service communications. Please also note the comments I made regarding WakeLocks and WiFiLocks for network comms. These tools appear quite dangerous for the Battery if used without care.</li> <li>If you want your service to exist as long as your child thread then I would suggest returning the <code>START_STICKY</code> flag from your service and allowing your app to bind to it (ref: <a href="http://developer.android.com/guide/components/bound-services.html" rel="nofollow">Bound Service</a> to see how it's getting on.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload