Java tutorial
//package com.java2s; /********************************************************************* * Mechanic - Hacking your car * * Copyright (C) 2013 Joerg Pleumann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * LICENSE file for more details. */ import java.util.Set; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.util.Log; public class Main { public static final String TAG = "Mechanic"; public static final String[] getBondedDeviceNames() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> devices = adapter.getBondedDevices(); String[] names = new String[devices.size()]; int i = 0; for (BluetoothDevice d : devices) { Log.d(TAG, "Found bonded device " + d.getName()); names[i++] = d.getName(); } return names; } }