Android Open Source - Bluetooth-Proximity-Lock Service Binder

From Project

Back to project page Bluetooth-Proximity-Lock.


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:
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);

  public T getService() {
    return weakService.get();

Java Source Code List