apache / apache/cordova-android
In low memory, using overview button causes ondeviceready but not onresume
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 16h 18m
- Merged PRs (30d)
- 11
Description
### Issue Type
- [ x] Bug Report
- [ ] Feature Request
- [ ] Support Question
## Description
I'm testing my app's onpause/onresume in low memory, so I've set "Don't keep activities" in Android's Developer Options. When this is set, and I use the "overview" button (aka app switcher, bottom right square) and choose my app again, onresume is never fired but ondeviceready is. Thus, there is no way to distinguish between the user starting the app (when I want the user to log in) and resuming it using the overview button (when I want to restore state).
## Information
When my app calls the camera plugin in low memory, both ondeviceready and onresume are fired upon return.
When testing with normal memory conditions, all three events seem to work correctly, except: when using the overview button to reselect my app, onresume fires, which I thought would only happen if the phone actually ran out of memory, which is not the case here. (But maybe that detail is correct behavior?) In any case, of course, I need this to work in low-memory conditions.
### Command or Code
I just put an alert() at the beginning of each of the ondeviceready and onresume handlers, indicating which handler is running.
### Environment, Platform, Device
This is on a physical Pixel 2 XL running Android 11; I see the same results when running in an emulator.
### Version information
Development machine is Linux (OpenSuSE Leap 15.1)
Android 11 on Pixel 2 XL
Cordova 10.0.0
cordova-plugin-camera 5.0.2
cordova-plugin-background-mode 0.7.3
cordova-plugin-autostart 2.3.0
I'm not using the last two yet, but my app will need them. I'm using many more plugins, but these are the only ones that seem relevant.
## Checklist
- [ x] I searched for already existing GitHub issues about this
- [ ] I updated all Cordova tooling to their most recent version
- [ x] I included all the necessary information above
Contributor guide
Research direction
Start by reproducing the ondeviceready and onresume behavior on Android 11 with “Don’t keep activities” enabled, using the overview button and the camera plugin scenario described. Compare the event sequences for a fresh launch, overview reselection, and return from the camera; done means the lifecycle events reliably distinguish starting the app from restoring it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100