Note that there are some explanatory texts on larger screens.

plurals
  1. POSend string from android to visual basic 2010
    text
    copied!<p>I want to send a string from Android to my PC (visual basic 2010) i try this one but it's not working. Please anyone help me..</p> <p>I get my Android Code from : <a href="http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/" rel="nofollow">http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/</a></p> <p>And its Look Like :</p> <pre><code>package com.zelacroix.bukumenu; import java.io.*; import java.net.*; import android.app.Activity; import android.os.*; import android.util.*; import android.view.View; import android.view.View.OnClickListener; import android.widget.*; public class TesKirim extends Activity { private EditText serverIp; private Button connectPhones; private String serverIpAddress = "192.168.1.2"; private boolean connected = false; private Handler handler = new Handler(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.teskirim); serverIp = (EditText) findViewById(R.id.server_ip); connectPhones = (Button) findViewById(R.id.connect_phones); connectPhones.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!connected) { serverIpAddress = serverIp.getText().toString(); if (!serverIpAddress.equals("")) { Thread cThread = new Thread(new ClientThread()); Toast.makeText(getApplicationContext(), "masuk if", 10) .show(); cThread.start(); } } } }); }; public class ClientThread implements Runnable { public void run() { try { InetAddress serverAddr = InetAddress.getByName(serverIpAddress); Log.d("ClientActivity", "C: Connecting..."); Socket socket = new Socket(serverAddr , 10000); connected = true; while (connected) { try { Log.d("ClientActivity", "C: Sending command."); PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter( socket.getOutputStream())), true); // where you issue the commands out.println("Hey Server!"); Log.d("ClientActivity", "C: Sent."); } catch (Exception e) { Log.e("ClientActivity", "S: Error", e); } } socket.close(); Log.d("ClientActivity", "C: Closed."); } catch (Exception e) { Log.e("ClientActivity", "C: Error", e); connected = false; } } }; }; </code></pre> <p>my Visual Basic is using UDP method.. And its Look Like : </p> <pre><code>Imports System.Net.Sockets Imports System.Net Imports System.IO Imports System.Text Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim udp_Client As New UdpClient(10000) Dim remoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0) Dim receiveBytes As [Byte]() = udp_Client.Receive(remoteIpEndPoint) Dim returnData As String = Encoding.ASCII.GetString(receiveBytes) ListBox1.Items.Add(returnData.ToString) udp_Client.Close() Catch ex As Exception ListBox1.Items.Add(ex.ToString()) End Try End Sub End Class </code></pre> <p>Please I really2 need to comunicate them..</p>
 

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