代码片段
activity
package com.example.day10_2;
import android.Manifest;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Parcelable;
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.Button;
import android.widget.ListView;
import com.example.day10.R;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class Main2Activity extends AppCompatActivity implements View.OnClickListener {
List<BluetoothDevice> list;
MyAdapter myAdapter;
BluetoothAdapter bluetoothAdapter;
BluetoothManager bluetoothManager;
BluetoothReceiver bluetoothReceiver;
Button start, stop, search;
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
initView();
request();
initDate();
}
public void initDate() {
bluetoothManager = (BluetoothManager) getSystemService