如何从apk发送字符串到Windows C#项目 [英] How do I send string from apk to windows C# project

查看:49
本文介绍了如何从apk发送字符串到Windows C#项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处搜索,但没有什么是我需要的。

您可以将其视为Android应用程序和Windows窗体之间的聊天客户端,我只需要在apk上发送某些内容Windows应用程序的字符串,用它做什么。



注意:我希望能够在同一个wifi网络上使用portforwarding或两个设备进行操作,而不是通过蓝牙或USB。



我尝试过:



试过其他人的项目,搜索google,youtube,github,...但我发现没有做到这一点。

I searched everywhere but nothing was what I needed.
You can look at it as a chat client between an android app and a windows form, I just need something on an apk to send a certain string to the windows application wich do something with it.

NOTE: I would like to be able to do it with portforwarding or just both devices on same wifi network, not trough bluetooth or USB.

What I have tried:

Tried other person's projects, searched google, youtube, github, ... but I found nothing that does this.

推荐答案

通常,你会有类似Web服务的东西在事物的接收端。如果您肯定想使用WinForm应用程序,则可能需要使用TCP客户端和服务器。如果你是编程新手,这不会是微不足道的,特别是在两个不同技术堆栈之间进行通信时。



对于C#方面,你可能想要设置 TcpListener 。这不会回答你的所有问题,但它会让你开始:



TcpListener类(System.Net.Sockets)| Microsoft Docs [ ^ ]



对于Android方面,这应该可以让你入门:



< a href =https://github.com/codepath/android_guides/wiki/Sending-and-Receiving-Data-with-Sockets>使用套接字发送和接收数据·codepath / android_guides Wiki·GitHub [< a href =https://github.com/codepath/android_guides/wiki/Sending-and-Receiving-Data-with-Socketstarget =_ blanktitle =New Window> ^ ] br />


如果您还不具备这方面的知识,则需要了解套接字通信,并确保设置防火墙/权限(双方)允许沟通。



你可以探索的另一个选择是WCF,虽然不确定它与Android合作的程度,这就是为什么我最后提到它。



Hello World,WCF的基本服务器/客户端示例 [ ^ ]
Typically, you'd have something like a web service on the receiving end of things. If you definitely want to use a WinForm app, you probably want to use a TCP client and server. If you're new to programming, this will not be trivial, especially when communicating between two different technology stacks.

For the C# side, you'll probably want to set up a TcpListener. This won't answer all of your questions, but it will get you started:

TcpListener Class (System.Net.Sockets) | Microsoft Docs[^]

For the Android side, this should get you started:

Sending and Receiving Data with Sockets · codepath/android_guides Wiki · GitHub[^]

If you don't already have the knowledge, you'll need to learn about sockets communication and make sure that your firewalls / permissions are set up (on both sides) to allow the communication.

Another option you can explore is WCF, though not sure how well this will cooperate with Android, which is why I mention it last.

Hello World, Basic Server/Client Example of WCF[^]


这篇关于如何从apk发送字符串到Windows C#项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆