Добавить в приложение текущие координаты GPS
Я делаю приложение "BluetoothScanner", которое сканирует устройства и выводит на экран название устройства, mac-адресс, время обнаружения и координаты (мои), где было обнаружено устройство. Ниже представлен метод, в котором описывается процесс обнаружения устройства и добавления его в listAdapter. Как можно в listAdapter добавить еще и отображение координат?
private final BroadcastReceiver devicesFoundReceiver = new BroadcastReceiver() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Date currentDate = new Date();
DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault());
String timeText = timeFormat.format(currentDate);
String dateText = dateFormat.format(currentDate);
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
listAdapter.add(device.getName() + "\n" + device.getAddress() + "\n" + dateText + " " + timeText );
listAdapter.notifyDataSetChanged();
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
scanningBtn.setText("Scan Bluetooth Devices");
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
scanningBtn.setText("Scanning in progress...");
}
}
};