Issue
I see some applications like Messenger, Zalo do not need notifications but still work in the background. How to do it. The devices I use are Xiaomi A1 (Android 8) and Nokia 6.1 (Android 8.1). Any solution guide is highly appreciated
Solution
Starting with Android 6.0 (API level 23), Android introduces two power-saving features that extend battery life for users: DOZE and APP STANDBY. These two features enforce many restrictions on your background processing while the phone is in Doze mode. You should read about Doze and app standby in the following link
https://developer.android.com/training/monitoring-device-state/doze-standby
Now, about your use case is that you want to receive the messages and incoming calls even when the app is not running. For this use case, Android announced High Priority FCM messages in GoogleIO2016. They are high priority Push message which grant the application temporary wakelock and network access, independent of Device's Doze state or if the app happens to be in the app standby. This allows the application to react to the message and notify the user in whatever way it wants about the instant message or incoming call.
For more about your use case, follow the below GoogleIO2016 Video from 08:30m to 10:30m https://www.youtube.com/watch?v=VC2Hlb22mZM&t=505s
and read about this use case on the first link in this answer.
Answered By - Abhishek Luthra
Answer Checked By - David Goodson (JavaFixing Volunteer)