服务冻结活动?
我有一个获取位置并将其发送到服务器的服务,我还有一个通过按钮启动和停止服务的活动。当我启动服务时,所有按钮都不起作用,一段时间后活动力关闭,提供等待或关闭的选项。什么可能导致问题?
I have a service that gets the location and sends it to a server, also I have an activity that starts and stops the service with a button. When I start up the service all the buttons do not work and after a while the activity force closes giving the option to wait or close. what could be causing the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前做过类似的事情......我不发布整个代码,只是主要的事情。这不会运行,我只是想给你一些想法,告诉你该做什么以及如何处理它。
魔法是在 sendUpdatesToUI 中完成的...我自己保存了所有不重要的方法,这些方法在您实现 LocationListener 时被覆盖 - 您最了解,您需要其中哪些方法。
它可能不会以这种方式运行,因为我剔除了所有无趣的东西,但它应该给
你
一个想法,如何编程一个位置线程,这不会冻结你的 UI。
玩得开心
I did something like that before ... I dont post the whole code, jsut the main thing. This wont run, i just want to give you the idea, of what to llok for and how to handle it.
The magic is done in sendUpdatesToUI... I saved myself all the unimportant methods that are overwritten when you implement LocationListener - you know best, which of them you need.
class:
}
It probably won't run that way, because I kicked out all the uninteresting stuff, but it should give you an idea, how to programm a locationthread, which won't freeze your UI.
Have fun