CAS-71 Crash in AttachDocumentActivity
I get the following crash java.lang.RuntimeException: Unable to start activity ComponentInfo{com.salesrabbit.android.sales.universal/com.getstream.sdk.chat.view.activity.AttachmentDocumentActivity}: java.lang.RuntimeException: You must initialize the API client first, make sure to call StreamChat.initialize when user is on the AttachDocumentActivty and application process is killed.
How to reproduce
- In Developer options, enable Do not keep activities and set Background process limit to No background process
- Open a conversation and attach a file to the conversation, say a pdf file for example
- Click on the attached pdf to preview it, and while on this screen
- Go to your home screen to move the app to the background
- Open app again, it crashes with the above error
@Chikrix , It has nothing to do with loading attachment file.
When Do not keep activities option is enabled, the Android OS will destroy an activity as soon as it is stopped.
It means if you are not on HomeActivity(where was initialized StreamChat), all features would be stopped after back from background.
It is not recommended to turn this option on because this may lead to unexpected issues on the apps, such as freezes, force closes and reboots.
@adrian09h that was how I could reproduce that crash as few users on my app were having that issue. I couldn't reproduce it any other way, testing with Do not keep activities is a good practice when testing and should be handled in my opinion
@adrian09h keeping the Don't keep activities and No background processes developer settings off doesn't prevent any crash or bug experienced when they are turned on. Process death is a reality of Android app development that needs to be tested for and handled. Enabling these settings is a way to test this scenario that users are going to experience when an app is in the background and the device needs more memory.
This problem is going to be completely resolved on the upcoming v4 release, I am going to close this issue. You can already try the beta version of v4 or otherwise subscribe to this issue #554 to get notified when v4 is released as stable.