Note that there are some explanatory texts on larger screens.

plurals
  1. POTransfer data between 2 android devices
    primarykey
    data
    text
    <p>I'd like write an app to transfer data between 2 android devices on the same wifi network, like as there is a share folder.</p> <p>How can i do this?</p> <p>Thanks</p> <p><strong>EDIT (My solution):</strong></p> <p><em>My Server wait for request</em></p> <pre><code>private boolean startServer() { try { server = new ServerSocket(port); } catch (IOException ex) { ex.printStackTrace(); return false; } return true; } public void runServer() { while (this.go) { try { Log.d("BurgerClub", "Server in attesa di richieste"); Socket s1 = server.accept(); OutputStream s1out = s1.getOutputStream(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter( s1out)); BufferedReader br = new BufferedReader(new FileReader(this.path)); String counter = br.readLine(); counter = counter != null ? counter : "000"; br.close(); bw.write(counter); bw.close(); s1.close(); } catch (IOException ex) { ex.printStackTrace(); } } } </code></pre> <p><em>My Client (Runnable object)</em></p> <pre><code>public void run() { try { this.openConnection(); // Se il socket è connesso if( !this.s1.isClosed() ) { InputStream is = this.s1.getInputStream(); BufferedReader dis = new BufferedReader(new InputStreamReader(is)); line = dis.readLine(); if( !this.previousCounter.equals(line.trim()) ) { ((BurgerClub_MonitorActivity) counterContext).runOnUiThread(new Runnable() { @Override public void run() { TextView edit = (TextView)(((BurgerClub_MonitorActivity) counterContext).findViewById(R.id.textActionCounter)); edit.setText(line); } }); this.previousCounter = line.trim(); } dis.close(); } } catch (ConnectException connExc) { connExc.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (Throwable ex) { ex.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload