From 07593d70349505d9c2e1fa2a855a172cb95460bc Mon Sep 17 00:00:00 2001 From: Timo T Date: Thu, 19 May 2022 12:43:28 +0200 Subject: [PATCH] Fix turn check worker exception (#6867) AndroidFileHandle uses Gdx.files internally --- android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt index 4ec3e1a175..0c5100817f 100644 --- a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt +++ b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt @@ -16,6 +16,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.DEFAULT_VIBRATE import androidx.core.app.NotificationManagerCompat import androidx.work.* +import com.badlogic.gdx.Gdx import com.badlogic.gdx.backends.android.AndroidApplication import com.badlogic.gdx.backends.android.DefaultAndroidFiles import com.unciv.logic.GameInfo @@ -256,6 +257,8 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame // We can't use Gdx.files since that is only initialized within a com.badlogic.gdx.backends.android.AndroidApplication. // Worker instances may be stopped & recreated by the Android WorkManager, so no AndroidApplication and thus no Gdx.files available val files = DefaultAndroidFiles(applicationContext.assets, ContextWrapper(applicationContext), false) + // GDX's AndroidFileHandle uses Gdx.files internally, so we need to set that to our new instance + Gdx.files = files gameSaver.init(files, null) } @@ -402,4 +405,4 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame notify(NOTIFICATION_ID_INFO, notification.build()) } } -} \ No newline at end of file +}