Has anyone seen a problem with the Android mobile app SDK not responding after the app has been sitting in the background?
I'm having a problem with the SDK in our Android app. It stops reporting data to Sitecatalyst after the app has been in the background for an extended period of time. It is communicating fine in the evening, but when I pick up the device in the morning, it isn't communicating to Sitecatalyst. It works on most devices, but I have found a handful (haven't identified the link yet) that this happens to on a daily basis. When I clear the app from memory and relaunch it, everything reports correctly.
I can see through my Charles proxy that there are communications with our servers and other 3rd party integrations, but not calls to Adobe. After I kill the app and relaunch it, I can see the calls flowing as expected.
Anyone else have experience with the SDK for mobile apps?
Yes, moving the call to onResume is the correct way to fix the issue. 🙂
For anything that extends Activity, you should be using the onResume() to call Config.collectLifecycleData() and onPause() to call Config.pauseCollectingLifecycleData().
You can always find more documentation on this here, specifically under the 'Lifecycle Metrics' header.
We have reproduced the issue on several devices - Samsung GS3 & GS4, Sony Xperia - and multiple versions of Android - 4.3, 4.4.2, 4.2.
The frustrating part is that it didn't happen everytime on all devices. I found one GS3 running 4.3 that it occurred every morning. It also takes over 7-hours in the background to produce the problem. It basically occured every morning, but we couldn't replicate it during other intervals during the day.
We just recently moved the startactivity to be after the onResume. Previously we had it after the onStart. That appears to have fixed the issue, but I'm not certain yet. I would love it if you could help take a look at the code or the logs to troubleshoot. Just let me know what I need to send you.
How are you currently implementing the start/stop lifecycle calls in the onResume/onPause methods (for each activity)?
If you are not, the SDK will be unable to queue or send hits.
If you are, it is possible there are errors there and we may need to review your code.
What device models and Android version are the devices you are having issues with?
Could you enable debug logging before the next time you move the app to the background on one of the affected devices?
Could take a look at the log to identify the possible cause.