There is an android application that, when enabled or in the tray, "listens" to SMS messages. When receiving special SMS messages, the application responds by changing the elements in the main activation and launching the "siren".

Problem: if the application did not start after the phone was turned on, then when the SMS arrives, my application does not respond at all.

Necessary: even if the application did not start, it should respond to received messages. If I'm not mistaken, the application can not run itself. In this case, you need to display some kind of push notification.

Question: How to implement this function correctly?

Possible solution: as far as I understand, you need to implement Service (stickyIntent), which will run with the phone turned on and "listen" to all SMS. And what to do with notifications? I found information only on notifications with Google Cloud or my own servers. Can I implement notifications locally?

    1 answer 1

    You must have a BroadcastReceiver declared in the manifest with the exported=true type flag:

     <receiver android:name=".SmsReceiver" android:enabled="true" android:exported="true" android:permission="android.permission.BROADCAST_SMS" > <intent-filter android:priority="2147483647" > <!-- 999 is highest system priority, so it's hack 2147483647 --> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> <!-- pre kitkat action --> <action android:name="android.provider.Telephony.SMS_DELIVER" /> <!-- kitkat action --> </intent-filter> </receiver> 

    Event handling should occur in the receiver of this Broadcast and if the BroadcastReceiver declared as exported=true , then it works even if the application has not been launched once.

    • Everything is so worth it, the only thing I have is not such a terrible priority) but only 1000, but I do not think that the problem is ivanovd422
    • Allow me not to believe that this receiver does not intercept. I ate a dog in sms, so alas I do not believe it :) - Barmaley