Commit 8799b498 authored by Matej Frančeškin's avatar Matej Frančeškin

Taisync - remove probing timer, use onResume as plug in detection event

parent 9c6b1ea7
......@@ -225,13 +225,21 @@ public class QGCActivity extends QtActivity
IntentFilter accessoryFilter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
registerReceiver(mOpenAccessoryReceiver, accessoryFilter);
probeAccessories();
} catch(Exception e) {
Log.e(TAG, "Exception: " + e);
}
}
@Override
public void onResume() {
super.onResume();
// Plug in of USB ACCESSORY triggers only onResume event.
// Then we scan if there is actually anything new
probeAccessories();
}
@Override
protected void onDestroy()
{
......@@ -701,12 +709,9 @@ public class QGCActivity extends QtActivity
private void probeAccessories()
{
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run()
{
// Log.i(TAG, "probeAccessories");
new Thread(new Runnable() {
public void run() {
Log.i(TAG, "probeAccessories");
UsbAccessory[] accessories = _usbManager.getAccessoryList();
if (accessories != null) {
for (UsbAccessory usbAccessory : accessories) {
......@@ -719,7 +724,7 @@ public class QGCActivity extends QtActivity
}
}
}
}, 0, 3000);
}).start();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment