Android Open Source - Bluetooth-Proximity-Lock Service Binder






From Project

Back to project page Bluetooth-Proximity-Lock.

License

The source code is released under:

Apache License

If you think the Android project Bluetooth-Proximity-Lock 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.javadog.bluetoothproximitylock.helpers;
// w ww.  j ava 2s .  c om
import android.os.Binder;

import java.lang.ref.WeakReference;

/**
 * Allows an activity to bind to a Service of type T.
 *
 * Implemented this way because of a bug in Android, see below:
 * http://www.mongrel-phones.com.au/default/how_to_make_a_local_service_and_bind_to_it_in_android
 */
public class ServiceBinder<T> extends Binder {
  private WeakReference<T> weakService;

  /**
   * @param service A reference to the service which will be bound.
   */
  public ServiceBinder(T service) {
    weakService = new WeakReference<>(service);
  }

  @SuppressWarnings("unused")
  public T getService() {
    return weakService.get();
  }
}




Java Source Code List

com.javadog.bluetoothproximitylock.BluetoothFragment.java
com.javadog.bluetoothproximitylock.MainActivity.java
com.javadog.bluetoothproximitylock.SignalReaderService.java
com.javadog.bluetoothproximitylock.helpers.BetterCompoundButton.java
com.javadog.bluetoothproximitylock.helpers.BluetoothManager.java
com.javadog.bluetoothproximitylock.helpers.CircularQueue.java
com.javadog.bluetoothproximitylock.helpers.DeviceLockManager.java
com.javadog.bluetoothproximitylock.helpers.ServiceBinder.java