Skip to content

Commit 0cbd3a8

Browse files
authored
Merge pull request #86 from fpvout/fix/broadcastIntentError
fix app crash when usb was disconnected and screen was off.
2 parents 9b1b94b + 5d5fc9a commit 0cbd3a8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/src/main/java/com/fpvout/digiview/MainActivity.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void usbDeviceApproved(UsbDevice device) {
246246
public void usbDeviceDetached() {
247247
Log.i(TAG, "USB - usbDevice detached");
248248
showOverlay(R.string.usb_device_detached_waiting, OverlayStatus.Disconnected);
249-
this.onStop();
249+
disconnect();
250250
}
251251

252252
private boolean searchDevice() {
@@ -339,14 +339,17 @@ private void hideOverlay() {
339339
autoHideSettingsButton();
340340
}
341341

342+
private void disconnect() {
343+
mUsbMaskConnection.stop();
344+
mVideoReader.stop();
345+
usbConnected = false;
346+
}
347+
342348
@Override
343349
protected void onStop() {
344350
super.onStop();
345351
Log.d(TAG, "APP - On Stop");
346-
347-
mUsbMaskConnection.stop();
348-
mVideoReader.stop();
349-
usbConnected = false;
352+
disconnect();
350353
}
351354

352355
@Override

0 commit comments

Comments
 (0)