【问题标题】:how to send and receive image through socket如何通过套接字发送和接收图像
【发布时间】:2012-01-20 10:21:07
【问题描述】:

我想将图像从一台安卓设备发送到一台或多台安卓设备。 所以我应该遵循哪种机制将图像从一个 android 设备发送到另一个 android 设备。 我是安卓新手。所以如果可能的话,然后给我逻辑(完成任务的方法)。 如果可能的话,请举例说明..

【问题讨论】:

    标签: android image sockets


    【解决方案1】:

    查看 SDK(API 级别 14+)中的 WiFiDirectDemo 示例。它完全符合您的要求: http://developer.android.com/resources/samples/WiFiDirectDemo/index.html

    WiFi 直连仅适用于运行 ICS 的设备。但是,套接字服务器/客户端代码是通用的,也可以通过 Wifi 网络重用:

    客户: http://developer.android.com/resources/samples/WiFiDirectDemo/src/com/example/android/wifidirect/FileTransferService.html

    服务器: http://developer.android.com/resources/samples/WiFiDirectDemo/src/com/example/android/wifidirect/DeviceDetailFragment.html FileServerAsyncTask。

    【讨论】:

    • 我应该将图像转换为二进制数组还是可以发送..???@Anirudh
    • 你不必......只需从文件的输入流中读取字节并将其写入套接字的输出流
    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 2013-12-31
    • 2012-02-12
    • 2013-09-11
    相关资源
    最近更新 更多