Only start Bluetooth in UI thread, WiFi needs background.
While we're at it, use `Thread`s rather than `AsyncTask`s because they are more concise. Not 100% sure, but I think `AsyncTask`s need to wait for the UI event loop to get to them in order kick off.
This commit is contained in:
parent
4bb2a0e0d0
commit
828cc272ee
@ -127,6 +127,14 @@ public class BluetoothSwap extends SwapType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't try to start BT in the background. you can only start/stop a BT server once, else new connections don't work.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void stopInBackground() {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (server != null && server.isAlive()) {
|
if (server != null && server.isAlive()) {
|
||||||
|
@ -72,15 +72,12 @@ public abstract class SwapType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startInBackground() {
|
public void startInBackground() {
|
||||||
start();
|
new Thread() {
|
||||||
/**
|
|
||||||
new AsyncTask<Void, Void, Void>() {
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
public void run() {
|
||||||
start();
|
SwapType.this.start();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}.execute();*/
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureRunning() {
|
public void ensureRunning() {
|
||||||
@ -90,23 +87,21 @@ public abstract class SwapType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ensureRunningInBackground() {
|
public void ensureRunningInBackground() {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
public void run() {
|
||||||
ensureRunning();
|
ensureRunning();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}.execute();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopInBackground() {
|
public void stopInBackground() {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
public void run() {
|
||||||
stop();
|
SwapType.this.stop();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}.execute();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user