Android background beacon detection (non-die-proof service)

Asked 2 years ago, Updated 2 years ago, 118 views

Be logged in status

app detects beacon in the background at the end of apps, if detected a beacon to try to look for ttwiwo die in the same time, ending services app. Services that don't die and how to make about the direction of opinion, please.

android service beacon

2022-09-22 19:33

3 Answers

You can prioritize services to reduce the likelihood that services will be terminated by the system. This is called a foreground service.

A foreground service is a service that is actively recognized by the user and is not considered a candidate for the system to abort in the event of low memory.

Even if a music app or exercise app leaves the app, it will be easy to understand if you think about how it runs in the background, showing the status of the app on the status bar.

Please read the Run Service in the foreground section of the document below to apply the code.


2022-09-22 19:33

As it means that the service will die at the same time as the app ends, I think the service will work in the same process as the calling component.


2022-09-22 19:33

From the service's onStartCommand, Try using returnSTART_STICKY


2022-09-22 19:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.