From c0d3fd58fd25e4627a6f8d64a22c5800e783ce07 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 19 Oct 2014 20:23:02 +0300 Subject: [PATCH] Expose the asset manager from Android::MainThread AFAICT the asset manager is tied to the application and not the activity, so this simple approach should be safe even if the activity gets destroyed and recreated due to orientation change or whatever. --- source/core/android/mainthread.cpp | 1 + source/core/android/mainthread.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/source/core/android/mainthread.cpp b/source/core/android/mainthread.cpp index 1e5fc11..6a3f865 100644 --- a/source/core/android/mainthread.cpp +++ b/source/core/android/mainthread.cpp @@ -10,6 +10,7 @@ namespace Msp { namespace Android { MainThread::MainThread(ANativeActivity *a): + asset_manager(a->assetManager), starting_up(true) { attach_to_activity(a); diff --git a/source/core/android/mainthread.h b/source/core/android/mainthread.h index 68da6c4..efd0fe0 100644 --- a/source/core/android/mainthread.h +++ b/source/core/android/mainthread.h @@ -20,6 +20,7 @@ public: private: ANativeActivity *activity; + AAssetManager *asset_manager; bool starting_up; Mutex startup_mutex; @@ -31,6 +32,8 @@ public: void wait_for_app_created(); void resume_startup(); + AAssetManager *get_asset_manager() const { return asset_manager; } + private: virtual void main(); -- 2.43.0