I am building an eBook reader app (primarily targeting android). The app displays list of books (image + text). But whenever the app is 're-initialized' (I am using it for lack of my understanding of correct term), all the images in the app stop loading with the below error.
This 're-initialization' I have noticed happening following scenarios -
- The app is running, toggle the Android system theme - Dark/Light theme (Happens only on some devices, not all, API 33)
- The app is running, and it receives an intent. Following is the intent filter defined -
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "com.xx.yy")]
- The app is the background for very long, when brought to foreground.
In all these cases OnCreate()
is called in the MainActivity
.
From the error in the Glide library, looks like it continuing to use the old activity instance. How can I re-initialize Glide library to use the new activity? or how can I fix this issue, or any workaround?
I am using # 2 above for fetching Google API OAuth token, and upon login the app is wrecked which is very poor experience. It happens on both debug and release build and multiple devices.
Unable to load image file '/data/user/0/com.xx.yy/files/CoverImage/a5c6f357-0458-4db1-9999-74387c2ee156.jpg'. -->
Java.Lang.IllegalArgumentException: You cannot start a load for a destroyed activity
java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity
at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:353)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:153)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:217)
at com.bumptech.glide.Glide.with(Glide.java:902)
at com.microsoft.maui.PlatformInterop.loadImageFromFile(PlatformInterop.java:244)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7884)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Please suggestion some fix or workaround for this, currently this is blocking issue for my app.