Android 套接字编程?
我需要一些关于 android 套接字编程的帮助。我使用 java 套接字编程制作了一个服务器-客户端原型。在服务器客户端场景中,我发送 1-10 的命令,并根据从客户端收到的命令执行一些任务。例如,当服务器收到命令时,它会向客户端发送 bufferedImage。它的(java原型)工作正常。在这种情况下,服务器和客户端都是java桌面应用程序,现在我想让android作为客户端。有人可以在这方面帮助我或者向我推荐android套接字编程的好资源吗?
(请注意 Android 不支持 BufferedImage 类。)
I need a little bit help regarding to android socket programming. I had made a server-client prototype using java socket programming. In server client scenario , I am sending commands from 1-10 and sever do some task according to command received from client. e.g. when server receives a command it sever will send a bufferedImage to the client. Its (java prototype) is working fine. In this scenario, both server and client a java desktop applications, Now I want to make android as a client. Can someone help me in this regard or suggest me good resources of android socket programming?
(Please note BufferedImage class is not supported by Android.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
移植您的应用程序没有问题。 Android 运行在 Java 之上,这与桌面版本非常相似。您所需要做的就是将 BufferedImage 迁移到简单字节数组,并在服务器端使用 ImageIO 。
There is no problem in porting your application. Android runs on Java, which very similar to desktop version. All you need is to migrate
BufferedImage
to simple byte array, and to useImageIO
on your server side.@Op。请注意,您在 Android 设备上可能还想在下载图像时保留 PARTIAL_WAKE_LOCK。
@Op. Do note that you on the Android device probably also want to keep a PARTIAL_WAKE_LOCK while you are downloading the image.