主界面
package com.example.mp;
import android.Manifest;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import com.example.mp.thread.ClientThread;
import com.example.mp.thread.ServiceThread;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
private BluetoothAdapter bluetoothAdapter;
private BluetoothManager bluetoothManager;
private Button mainButtonOpen;
private Button mainButtonClose;
private Button mainButtonSearch;
private Button mainButtonShow;
private ListView mainListLeft;
private ListView mainListRight;
private ArrayAdapter aaa;
private ArrayAdapter bbb;
private List<String> name=new ArrayList<>();
private List<String> devices=new ArrayList<String>();
private List<BluetoothDevice> left_devices=new ArrayList<BluetoothDevice>();
private List<BluetoothDevice> device=new ArrayList<BluetoothDevice>();
private BaseReceiver br;
@SuppressLint("HandlerLeak")
private Handler han=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if( msg.what==102){
Toast.makeText(MainActivity.this, ""+msg.obj, Toast.LENGTH_SHORT).show();