![](/img/trans.png)
[英]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.