Reputation: 404
I'm working on a utility application in which when an SMS is received with a specific message I need to send a reply message. To know the sms_received event i used a broadcast receiver. Below it the code of it in the manifest file.
<receiver
android:name=".SMSReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="900">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I had defined runtime permissions and the broadcast receiver is triggering when sms is received and executing its task and everything working fine as expected. But the problem is it stops working after some time. Maybe the Android device is killing my application process. I know this by going to app-info and there the force stop button is disabled. which means no process related to the app is running.
I had another application on same mobile in which I used the FCM and its process is running for several days. not only this many apps like whatsapp, telegram working for several days even those application not opened. I see this by opening app-info and there i seen force-stop button enabled.
how those apps working in background for several days? what I'm missing in my application? how to run my broadcast receiver for several days? any suggestions are greatly appreciated, thanks in advance.
Upvotes: 2
Views: 241