Просмотр исходного кода

Dismiss system alerts in playground app

Hopefully, this will prevent Detox from timing out when a system alert pops up on the screen.
Guy Carmeli 6 лет назад
Родитель
Сommit
a7391bb664

+ 13
- 1
playground/android/app/src/main/java/com/reactnativenavigation/playground/MainActivity.java Просмотреть файл

@@ -1,6 +1,18 @@
1 1
 package com.reactnativenavigation.playground;
2 2
 
3
-import com.reactnativenavigation.*;
3
+import android.content.Intent;
4
+
5
+import com.reactnativenavigation.NavigationActivity;
4 6
 
5 7
 public class MainActivity extends NavigationActivity {
8
+    @Override
9
+    public void onWindowFocusChanged(boolean hasFocus) {
10
+        dismissSystemAlertsToPreventDetoxFromTimingOut(hasFocus);
11
+    }
12
+
13
+    private void dismissSystemAlertsToPreventDetoxFromTimingOut(boolean hasFocus) {
14
+        if (! hasFocus) {
15
+            sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
16
+        }
17
+    }
6 18
 }