开发者

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜