Android Open Source - GeoCarDroid Bth Device Manager






From Project

Back to project page GeoCarDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project GeoCarDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.geocar.bluetooth;
//from  w  w  w  . j av a 2s.co m
import java.util.Set;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

public class BthDeviceManager {
  private static String BTH_GEOCAR = "GeoCar";  
  public static String SPP_UUID = "00001101-0000-1000-8000-00805F9B34FB";
  // Get the default adapter
  private BluetoothAdapter mBluetoothAdapter;// = BluetoothAdapter.getDefaultAdapter();
  
  public BthDeviceManager(){
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  }
  

  public boolean isEnabled(){
    return (mBluetoothAdapter!=null)? mBluetoothAdapter.isEnabled():false;
  }
  
  public BluetoothDevice getGeoCar(){
    return getDevice(BTH_GEOCAR);
  }
  
  
  private BluetoothDevice getDevice(String name){
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    // If there are paired devices
    if (pairedDevices.size() > 0) {
        // Loop through paired devices
        for (BluetoothDevice device : pairedDevices) {
          if( device.getName().equals(name)){
            return device;
          }
        }
    }
    return null;
  }
}




Java Source Code List

com.geocar.bluetooth.AlertType.java
com.geocar.bluetooth.BthDeviceManager.java
com.geocar.bluetooth.ConnectThread.java
com.geocar.bluetooth.ConnectedThread.java
com.geocar.bluetooth.ConnectionHandler.java
com.geocar.bluetooth.GeoSendDataThread.java
com.geocar.bluetooth.SocketHandler.java
com.geocar.geocarconnect.FileInfo.java
com.geocar.geocarconnect.FileManager.java
com.geocar.geocarconnect.GeoCarAlert.java
com.geocar.geocarconnect.MainActivity.java
com.geocar.geocarconnect.PrefActivity.java
com.geocar.geocarconnect.Settings.java
com.geocar.geocarconnect.StartMenu.java
com.geocar.sms.SmsListener.java