my problem is that when I run the android app, it takes a minute for this method to run if the printer is offline. I would like to run it on another thread in the background and the original thread could run uninterrupted. Thanks for any advice, happy codding!
public class MainActivity extends WebView {
public PrinterManager printerManager;
public final int REQUEST_COARSE_LOCATION_PERMISSIONS = 52;
private JSPlugin plugin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(mBluetoothReceiver, filter);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case REQUEST_COARSE_LOCATION_PERMISSIONS: {
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//printerManager.connectDefaultPrinter(0);
//printerManager.connectDefaultPrinter(1);
printerManager.connectAll(); <----- This method call i want to do in new thread
} else {
Toast.makeText(this,
"NO Bluetooth RIGHTS",
Toast.LENGTH_LONG).show();
}
return;
}
}
}