将字符串从 Android 手机发送到 PC

发布于 2024-10-10 02:18:41 字数 1436 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我鬧 2024-10-17 02:18:44

我现在实际上正在实现 Android 和 PC 之间的套接字解​​决方案!一旦您了解了套接字背后的基础知识(通过阅读 Sebastian 建议的链接),您就可以使用以下链接作为代码指南来让您的仪器说话:

我正在使用上面 Android 套接字示例链接中的客户端代码,以及 Beej 网站上的 Unix 套接字示例中的服务器示例(我被告知我是 stackoverflow 的新用户,所以我'我将把它作为评论链接到这个答案)。 Unix 套接字服务器被设置为接收来自客户端的连接和数据包,然后发回应答并关闭套接字。我对此进行了修改,以便服务器只是一个循环,不断要求用户在控制台输入输入。这不是一个漂亮的解决方案(即 PC 端没有用户界面),但它至少会为您提供基础知识。你可以稍后再做。

I'm actually implementing a socket solution between Android and PC right now! Once you understand the basics behind sockets (by reading the links that Sebastian suggested), you can use the following links as code guides to make your instruments talk:

I'm using the client code from the Android socket example link above, and the server example from the Unix socket example on Beej's website (I've been informed that I'm a new user to stackoverflow, so I'm going to link that as a comment to this answer). The Unix socket server is set up to receive a connection and a packet from the client, then send an answer back and close the socket. I modified this so that the server is just a loop that continuously asks for input from the user at the console. It's not a pretty solution (i.e. no user interface on the PC side), but it will at least give you the basics. You can make it pretty later.

薯片软お妹 2024-10-17 02:18:43

在 Android 中执行此操作之前,我建议您阅读 Java 网络的基础知识:

尝试阅读一本好书。一旦您知道如何用 Java 执行此操作,就可以在 Android 和 Android 中实现一个测试客户端。您的 PC 中的测试服务器。

Before doing this in Android, I recommend you read the basics of Java networking:

Try to get access to a good book. Once you know how to do it in Java, implement a test client in Android & a test server in your PC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文