[英]How to get all <uses-permission> of other particular application installed on the device (Android)?
[英]How to send data to the same application installed on other android device using wifi
我在我的Android设备上有一个应用程序,如“A”和安装在其他Android设备上的相同应用程序,如“B”,现在我想使用WIFI服务从应用程序“A”发送数据到应用程序“B”。 所以请建议我如何实现此功能。
我多次尝试从谷歌获得帮助,但一切都是徒劳的。 它可以从WIFI直接或NFC。
您可以使用简单的p2p架构。
您将需要使用this , this和一对与您需要发送的数据类型相关的流,如下所示 。
在发件人方面:
Socket s = new Socket(IP,PORT);
s.connect();
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
dos.write("hello".toByteArray());
然后在接收方:
ServerSocket ss = new ServerSocket(PORT);
Socket s = ss.accept(); //This call will block execution, use separate thread
DataInputStream dis = new DataInputStream(s.getInputStream);
byte[] data = dis.read();
使用此功能,您可以发送和接收字节,只需使用适用于您的数据类型的流。
当然,一旦建立连接,两个客户端都可以发送/写入,只需制作适当的输入/输出流。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.