package com.example.devicelist;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import java.io_OutputStream;
import java.util.Set;
import java.util.ArrayList;
import android.widget.Toast;
import android.widget.ArrayAdapter;
import android.widget.AdapterView;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.content.Intent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
public class DeviceList extends AppCompatActivity implements OnClickListener {
//widgets
private Button btnPaired;
private ListView devicelist;
//bluetooth
private BluetoothAdapter myBluetooth = null;
private Set<BluetoothDevice> pairedDevices;
private OutputStream outStream = null;
public static String EXTRA_ADDRESS = "device_address";
//if the device has bluetooth
BluetoothAdapter myBluetooth = BluetoothAdapter.getDefaultAdapter();
if (myBluetooth == null){
//Show a mensag. that the device has no bluetooth adapter
Toast.makeText(getApplicationContext(), "Bluetooth Device not Available", Toast.LENGTH_LONG).show();
//finish apk
finish();
}
else if (!myBluetooth.isEnabled()){
//Ask the user to turn on the bluetooth
Intent turnBTon = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnBTon, 1);
}