Add BleUtil.java and go:generate commands to create a jar for

inclusion by gogio.
This commit is contained in:
Greg 2019-10-30 12:07:24 -04:00
parent c9f3733aee
commit 8576d3e4c5
2 changed files with 37 additions and 0 deletions

35
BleUtil.java Normal file
View File

@ -0,0 +1,35 @@
package st.wow.git.ble;
import java.lang.Runnable;
import android.util.Log;
import java.lang.Class;
import java.lang.ClassLoader;
import java.lang.reflect.Constructor;
import android.os.Handler;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
public class BleUtil {
public void Enable(Context ctx) {
Log.d("gio", "BleUtil Enable: manager");
BluetoothManager manager = (BluetoothManager) ctx.getSystemService(ctx.BLUETOOTH_SERVICE);
Log.d("gio", "BleUtil Enable: adapter");
BluetoothAdapter ad = (BluetoothAdapter) manager.getAdapter();
if (ad == null || !ad.isEnabled()) {
Log.d("gio", "BleUtil Enable: handler");
Handler handler = new Handler(ctx.getMainLooper());
//BleEnabler en = new BleEnabler(ctx, ad);
Log.d("gio", "BleUtil Enable: Intent");
Intent enableBtIntent = new Intent(ad.ACTION_REQUEST_ENABLE);
Log.d("gio", "BleUtil Enable: handler.post");
handler.post(new Runnable() {
public void run() {
ctx.startActivity(enableBtIntent);
}
});
}
}
}

View File

@ -21,6 +21,8 @@ import (
"gioui.org/widget/material"
"gioui.org/font/gofont"
_ "gioui.org/permission/bluetooth"
)
type conf struct {