4040import com .adafruit .bluefruit .le .connect .ble .BleDevicesScanner ;
4141import com .adafruit .bluefruit .le .connect .ble .BleManager ;
4242import com .adafruit .bluefruit .le .connect .ble .BleUtils ;
43+ import com .adafruit .bluefruit .le .connect .ui .utils .DialogUtils ;
4344import com .adafruit .bluefruit .le .connect .ui .utils .ExpandableHeightExpandableListView ;
4445
4546import java .util .ArrayList ;
@@ -164,7 +165,7 @@ public void run() {
164165
165166 // Check if bluetooth adapter is available
166167 final boolean wasBluetoothEnabled = manageBluetoothAvailability ();
167- final boolean areLocationServicesReadyForScanning = manageLocationServiceAvailabiltyForScanning ();
168+ final boolean areLocationServicesReadyForScanning = manageLocationServiceAvailabilityForScanning ();
168169
169170 // Reset bluetooth
170171 if (autoResetBluetoothOnStart && wasBluetoothEnabled && areLocationServicesReadyForScanning ) {
@@ -372,15 +373,16 @@ private boolean manageBluetoothAvailability() {
372373 }
373374 if (errorMessageId > 0 ) {
374375 AlertDialog .Builder builder = new AlertDialog .Builder (this );
375- builder .setMessage (errorMessageId )
376+ AlertDialog dialog = builder .setMessage (errorMessageId )
376377 .setPositiveButton (R .string .dialog_ok , null )
377378 .show ();
379+ DialogUtils .keepDialogOnOrientationChanges (dialog );
378380 }
379381
380382 return isEnabled ;
381383 }
382384
383- private boolean manageLocationServiceAvailabiltyForScanning () {
385+ private boolean manageLocationServiceAvailabilityForScanning () {
384386
385387 boolean areLocationServiceReady = true ;
386388
@@ -397,9 +399,10 @@ private boolean manageLocationServiceAvailabiltyForScanning() {
397399 if (!areLocationServiceReady ) {
398400
399401 AlertDialog .Builder builder = new AlertDialog .Builder (this );
400- builder .setMessage (R .string .dialog_error_nolocationservices_requiredforscan_marshmallow )
402+ AlertDialog dialog = builder .setMessage (R .string .dialog_error_nolocationservices_requiredforscan_marshmallow )
401403 .setPositiveButton (R .string .dialog_ok , null )
402404 .show ();
405+ DialogUtils .keepDialogOnOrientationChanges (dialog );
403406 }
404407 }
405408
@@ -433,9 +436,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
433436 resumeScanning ();
434437 } else if (resultCode == Activity .RESULT_CANCELED ) {
435438 AlertDialog .Builder builder = new AlertDialog .Builder (this );
436- builder .setMessage (R .string .dialog_error_no_bluetooth )
439+ AlertDialog dialog = builder .setMessage (R .string .dialog_error_no_bluetooth )
437440 .setPositiveButton (R .string .dialog_ok , null )
438441 .show ();
442+ DialogUtils .keepDialogOnOrientationChanges (dialog );
443+
439444 }
440445 } else if (requestCode == kActivityRequestCode_Settings ) {
441446 // Return from activity settings. Update app behaviour if needed
0 commit comments