Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(android): write the session cookie down when the app leaves the screen

Mauriceef5deada83c2
diff --git a/client/android/app/src/main/java/com/liketrek/trek/MainActivity.java b/client/android/app/src/main/java/com/liketrek/trek/MainActivity.java
index ff9238f4c..3491995d1 100644
--- a/client/android/app/src/main/java/com/liketrek/trek/MainActivity.java
+++ b/client/android/app/src/main/java/com/liketrek/trek/MainActivity.java
@@ -10,6 +10,7 @@ import android.view.KeyboardShortcutGroup;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
+import android.webkit.CookieManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -90,6 +91,18 @@ public class MainActivity extends BridgeActivity {
if (group != null) data.add(group);
}
+ /**
+ * The web view keeps new cookies in memory and writes them to disk on its
+ * own schedule, about half a minute later. An app Android ends in that time
+ * (swiped away, or reclaimed for memory) forgets the sign-in it just had, so
+ * the session is written down whenever the app leaves the screen.
+ */
+ @Override
+ public void onPause() {
+ super.onPause();
+ CookieManager.getInstance().flush();
+ }
+
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);