如何在Android的Socket连接? [英] how to create Socket connection in Android?
问题描述
我有一个应用程序,我需要创建socket连接。我的要求是,一旦我的插座连接建立它需要活着,直到我亲自将其关闭。每3分钟我必须将数据包发送到另一端。任何人都可以提供我一些code样品与将帮助我做到这一点?
I have an application where i need to create socket connection. My requirement is, once my socket connection is established it need to be alive until i personally close it. Every 3 minutes i have to send data packets to the other end. Can anyone provide me some code sample with will help me to do this?
推荐答案
下面是另外一个例子插座使用: <一href="http://thinkandroid.word$p$pss.com/2010/03/27/incorporating-socket-programming-into-your-applications/">Incorporating socket编程到您的应用程序
Here's another example for socket usage: Incorporating socket programming into your applications
您可能希望一个服务
一样,所以应用程序并不需要激活所有的时间(见中提到的唤醒锁问题彼得的答案)
You might want to make that a Service
as well, so that the application doesn't need to be active all the time (see the wake-lock issue mentioned in Peter's answer)
这篇关于如何在Android的Socket连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!