I made an app that must be running in the background. The app basically register incoming calls and send timestamp to my server. Problem is that app is not working properly when it's killed after some time. I assume that OS simply kills my app however I don't know why.
Here's how I register my app in AndroidManifest.xml
file
<receiver
android:enabled="true"
android:name=".receiver.CallReceiver">
<intent-filter android:priority="99">
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
<intent-filter android:priority="100">
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
And here's my CallReceiver
class CallReceiver: BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// a lot of logic to send request using retrofit to my server
}
}
So problem is that after some time maybe (6-10 hours) App doesn't send any information to server. Why is it? After opening app again it starts to send data again.