Skip to content

Instantly share code, notes, and snippets.

@RobLewis
RobLewis / ReactiveServiceConnection.java
Created December 1, 2018 17:59
Bind and Unbind to an Android Service reactively
package net.grlewis.wifithermocouple;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
@RobLewis
RobLewis / CustomOperationExample.java
Last active April 12, 2023 06:41
Simple example of usage of RxBleCustomOperation — create an Observable that emits the Bluetooth GATT object
package net.grlewis.cufftest;
import android.bluetooth.BluetoothGatt;
import com.polidea.rxandroidble2.RxBleCustomOperation;
import com.polidea.rxandroidble2.internal.connection.RxBleGattCallback;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.annotations.NonNull;
@RobLewis
RobLewis / gist:a0b879c5db3bdd1a71e6562117f857f3
Last active March 19, 2018 22:30
Managing BLE connections with RxAndroidBle (RxJava2 version)
/*
The RxJava2-compatible version of the great Android Bluetooth LE library RxAndroidBle is out.
There are some changes I found a bit confusing and I'm hoping the discussion and code here
may help others.
The authors have retained the convention that the device.establishConnection() method
returns an Observable that emits one item: the connection to the Bluetooth device.
This Observable<RxBleConnection> may signal errors like "timeout" or "already connected"
but--importantly--it will NEVER call the Subscriber's .onComplete() handler.
@RobLewis
RobLewis / WorldSeriesOddsGist_.idea_description.html
Created October 29, 2017 23:50
Recursive coin-flip probability computation
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>