Android Question Working with intents: Services (running or not)

KMatle

Expert
Licensed User
Longtime User
This is a general question about lifecycle as there are many questions about it like "why doesn't my service start when the app get's swiped", etc. As far as I understood it (and tested it with e.g. FCM messages, SMS interceptions) you "set" a listener (intent) so Android will call your service if the intent occurs. If so, the given service will start.

On my Huawei Phone there's a setting ("protected apps") which will completely stop the app if it's not set to "protected" (enery savings menu). Not knowing this made me mad when I started with FCM messaging. Even WhatsApp did not receive messages (notifications) when I bought my phone 2 years ago (they made an update later to add it to the "whitelist"). However. My tests with intents are all positive. My apps do what I assume they should (= service starts when the intent occurs) (Android 4-6).

Back to my question: I see some threads about services NOT starting for some reason. Some answers recommend to work with phone wake state.

Can anyone bring some light into this?

My point of view:

- all of my apps work reliable using intents (Android 4-6) NOT usind phone wake state or other
- I did not try on Android 7 (I assume they will work, too)
- when I swipe my app, the service still starts (maybe it's a test issue some users have not knowing that the app has to be started ONCE to get the intent to work)
- So no problems here but others have (I assume not all of them have bugs in their apps)
 
Top