you can say that I am new to Android development, I need help to synchronize some data on two devices with my application, I did everything necessary, like finding available devices and pairing and decoupling ... all I now need to establish a connection between two devices and send and receive data to explain more, I need to select a device from my list and connect to it, after which I can say that I have a text box and a text box and a button, when I press the button, I need to avit text into the text field of the first device in a textual representation of the device and vice versa. here is all my code:
import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.BroadcastReceiver; import android.content.Context; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Set; import java.util.UUID; import android.content.Intent; import android.content.IntentFilter; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { private static final int REQUEST_ENABLE_BT = 1; private Button onBtn; private Button offBtn; private Button listBtn; private Button findBtn; private TextView text; private BluetoothAdapter myBluetoothAdapter; private Set<BluetoothDevice> pairedDevices; private ArrayList<BluetoothDevice> devices; private ListView myListView; private ArrayAdapter<String> BTArrayAdapter; private String tag = "debugging"; protected static final UUID MY_UUID = UUID .fromString("00001101-0000-1000-8000-00805F9B34FB"); protected static final int SUCCESS_CONNECT = 0; protected static final int MESSAGE_READ = 1; private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Log.i(tag, "in handler"); super.handleMessage(msg); switch (msg.what) { case SUCCESS_CONNECT:
source share