I have this code working in Android Build built stand alone however when I implement it in Unreal and call it, the callback does not trigger. Which is called via FJavaClassObject class. What I have read the callback should be triggering.
These are snippets of code:
//Called in a function
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
//Call for runtime permissions
m_Activity.requestPermissions(l_Permissions, 50);
}
//Getting the Manager for Bluetooth
m_BluetoothManager_BLE = (BluetoothManager) m_Activity.getSystemService(Context.BLUETOOTH_SERVICE);
//Getting the Bluetooth Adapter
m_BluetoothAdapter_BLE = m_BluetoothManager_BLE.getAdapter();
//Getting the BLE Scanner
m_BleScanner = m_BluetoothAdapter_BLE.getBluetoothLeScanner();
ScanSettings l_ScanSettings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
.build();
try
{
//Starting the Scan for BLE Devices
Log.d(m_TAG, "Starting Scan...");
m_BleScanner.startScan(new ArrayList<ScanFilter>(), l_ScanSettings, fn_BLE_Scan_Callback);
}
}
///CallBack
private ScanCallback fn_BLE_Scan_Callback = new ScanCallback()
{
@Override
public void onScanResult(int callbackType, final ScanResult result)
{
super.onScanResult(callbackType, result);
//Add Scan for Specific Devices
Log.i(m_TAG, "Remote device name: " + result.getDevice().getName());
m_BluetoothGatt = result.getDevice().connectGatt(m_Activity.getApplicationContext(), false, fn_GattCallback);
m_BleScanner.stopScan(fn_BLE_Scan_Callback);
}
@Override
public void onBatchScanResults(List<ScanResult> results)
{
Log.i(m_TAG, "Remote device name: ");
}
@Override
public void onScanFailed(int errorCode)
{
Log.i(m_TAG, "Scan Failed Error Code: " + errorCode);
//howToGetString(“Error Scan Failed”);
}
};