rayman
rayman

Reputation: 21616

Connection problem on Boot Completed issue

I am trying to run my service as soon as boot is completed. I know how to do it, but this is the prob:

the service is running as soon as it get the boot completed intent, but my service cant open any HttpUrlConnections

I get that error:

    10-26 09:53:50.400: ERROR/HttpHandler(1165) Host is unresolved: my.host:8080

assume the this hosts works fine as soon as i launch my service manually after boot up with a launcher.

Is there a problem with connections when the device is booting up? maybe it's not ready for opening connections while it's booting up?

any ideas? or how should I fix that??

thanks,

ray.

Upvotes: 1

Views: 657

Answers (2)

rayman
rayman

Reputation: 21616

In the end I solved it by using a handler which delay for like 20000 seconds, the device manage to finish boot properly, and then it's available for networking.

thanks all.

Upvotes: 0

Reuben Scratton
Reuben Scratton

Reputation: 38727

Suggest you listen for the broadcast intent android.net.connectivity.CONNECTIVITY_ACTION . There's a working example of how to do so here on stackoverflow.

Upvotes: 2

Related Questions