Back to project page lamp.
The source code is released under:
GNU General Public License
If you think the Android project lamp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package cz.tomsuch.lampicka.util; //w w w. j a v a 2 s. co m import android.bluetooth.BluetoothDevice; import android.os.ParcelUuid; import android.os.Parcelable; /** * Wrapper around BluetoothDevice, to wrap persisting the class, which could not * be manually instantiated * */ public class BluetoothDeviceWrapper { private String address = null; private String name = null; private ParcelUuid uuids[] = null; /** * Default constructor, from correctly obtained BluetoothAdapter * * @param device * BluetoothDevice from BluetoothAdapter * */ public BluetoothDeviceWrapper(BluetoothDevice device) { this(device.getAddress(), device.getName(), device.getUuids()); } /** * Helper constructor used by {@link Preferences} to restore device from * shared preferences * * @param address * mac address of persisted device * @param name * name of persisted device * @param uuids * service uuids of persisted device * */ public BluetoothDeviceWrapper(String address, String name, ParcelUuid[] uuids) { this.setAddress(address); this.setName(name); this.setUuids(uuids); } /** * Constructor working with * * @param parcelableExtra * if device is obtained via * Activity.getIntent().getParcelableExtra(String key) * */ public BluetoothDeviceWrapper(Parcelable parcelableExtra) { this((BluetoothDevice) parcelableExtra); } /** * Wrapper around device service uuids * */ public ParcelUuid[] getUuids() { return uuids; } /** * Wrapper setter of device service uuids * * @param uuids * device service uuids * */ public void setUuids(ParcelUuid uuids[]) { this.uuids = uuids; } /** * Wrapper around device name * */ public String getName() { return name; } /** * Setter for device name * * @param name * Device name * */ public void setName(String name) { this.name = name; } /** * Wrapper for device mac address * */ public String getAddress() { return address; } /** * Setter for device mac address * */ public void setAddress(String address) { this.address = address; } /** * Validates if device is usable, after persist-restore cycle * */ public boolean isValid() { return this.address != null; } }