I am writing an application for Android >=12, in which I use ForegroundService to get the user's coordinates and synchronize them with the server.
I don't have any apps hosted anywhere yet (I'm a beginner).
When I test my application by installing it from Android Studio, everything is fine - the application is installed, the service is running, the coordinates are saved to the server.
But when I created my signature for the application and installed it on my smartphone by downloading it from the server, the following unpleasant moments arose:
- When installing the application, a warning appears that the developer is unknown. And the user is strongly discouraged from installing this application.
- My ForegroundService service shuts down periodically at certain times. And it does not restart, despite the "Autorun" setting enabled by the user.
- After closing a running service, for example, with the standard MIUI "Security" application when clearing memory, and the subsequent automatic start of the service (the "Autorun" setting is enabled by the user), GPS coordinate detection (FusedLocationProviderClient) stopped working.
After studying the issue, I came across a post that says how to properly organize ForegroundService so that it is not nailed by the system. By executing
adb shell dumpsys > tmp.txt
, found out that FS is designed correctly, everything is functioning properly.
Proc #18: prcp F/S/FGS ---N t: 0 8656:com.example.my/u0a368 (fg-service)
but:
package: com.example.my
Historical Process Exit for uid=10368
ApplicationExitInfo #0:
timestamp=2023-06-01 09:43:52.752 pid=7411 realUid=10368 packageUid=10368 definingUid=10368 user=0
process=com.example.my reason=10 (USER REQUESTED) subreason=21 (FORCE STOP) status=0
importance=125 pss=99MB rss=217MB description=stop com.example.my due to from process:com.android.vending state=empty trace=null
This is despite the fact that, of course, I did not complete anything myself.
And this bothers me:
due to from process:com.android.vending.
In this regard, I ask you to suggest and guide me on the right path:
A. Do I understand correctly that these surprises began to occur due to the absence of me and my app on Google Play?
B. If I host the application in Google Play, will it solve my problem?
C. If I am mistaken in questions A and B, I ask you to guide me on the right path.