Added UI thread methods to AndroidExecutor.

This commit is contained in:
akwizgran
2016-08-20 17:06:52 +01:00
parent dbdf567d4e
commit 28be7d5de3
10 changed files with 97 additions and 45 deletions

View File

@@ -125,12 +125,13 @@ class DroidtoothPlugin implements DuplexPlugin {
// BluetoothAdapter.getDefaultAdapter() must be called on a thread
// with a message queue, so submit it to the AndroidExecutor
try {
adapter = androidExecutor.submit(new Callable<BluetoothAdapter>() {
@Override
public BluetoothAdapter call() throws Exception {
return BluetoothAdapter.getDefaultAdapter();
}
}).get();
adapter = androidExecutor.runOnBackgroundThread(
new Callable<BluetoothAdapter>() {
@Override
public BluetoothAdapter call() throws Exception {
return BluetoothAdapter.getDefaultAdapter();
}
}).get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted while getting BluetoothAdapter");