[Android] AppState 'inactive' not triggered on Android
See original GitHub issueDescription
When listening to an AppState change, inactive
is never triggered on Android, only background
.
Reproduction Steps
- Setup a
change
listener on AppState. - Output the current app state in the listener function.
- Send the app to the background (go to home screen) and notice
background
is logged, but neverinactive
Sample Code
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange(currentAppState) {
console.log(currentAppState); // never outputs 'inactive' on android
}
Additional Information
- React Native version: 0.43.3
- Platform: Android
- Development Operating System: macOS
- Testing on: Android Simulator with a Nexus 5 with Nougat
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13
Top Results From Across the Web
react native AppState has no 'inactive' state on Android
Its not a bug. Android implementation of AppState component has only 'active' and 'background' state. Just curious, why do you want to show...
Read more >AppState - React Native
[iOS] inactive - This is a state that occurs when transitioning between foreground & background, and during periods of inactivity such as ...
Read more >Activity state changes - Android Developers
Different events, some user-triggered and some system-triggered, can cause an Activity to transition from one state to another.
Read more >React Native AppState - Active | Background | Inactive
background – The app is running in the background. The user is either: using another app; on the home screen; [Android] on another...
Read more >Using AppState in React Native to improve performance
The above states are given on both Android and iOS, but iOS supports an additional AppState called inactive , which occurs when the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not aware that the issue is solved. It would be required to take action when the app goes into background, e.g. covering the app’s screen for privacy reasons, so that the system’s screenshot in the app-switch does not show the content of the app, but it’s lock screen.
+1. The inactive state is not sent when receiving a phone call aswell.
Edit: Have a look at AppStateModule. It seems that there are only three states possible:
uninitalized
,foreground
andbackground
. Correct me if I’m wrong, but I don’t think that Android has the inactive state, so that would explain why it was not implemented on Android. It would be a good thing to mention in the docs.