I’m writing an android app that has a standard activity, but also needs to monitor incoming/outgoing calls and texts at all times. In addition, the app needs to notify users of information once a day without having the activity open. The information it notifies users of is stored in a database, so communication with the activity is not necessary. I’ve been researching for a week and still can’t decide how to go about doing this. My instinct tells me I need a remote service that has a constantly running broadcast receiver, but every remote service example I see is overly complicated. Could anyone help me better understand what steps I need to take? Thanks in advance.
Share
Um, no. I say that, because:
Use
BroadcastReceiversregistered in your manifest for broadcasts that can occur at any time, as they will get control even if nothing else of your application is running. Use anIntentServicefor doing any “heavy lifting” that is needed by thoseBroadcastReceivers, asBroadcastReceiverget control (inonReceive()) on the main application thread and therefore should do as little work as possible. Also, useAlarmManagerto signal aBroadcastReceiver(or, possibly, yourIntentService) to raise aNotificationfor your once-daily event.Also, please be advised that there is no way for you to “monitor…outgoing…texts”, and that to “monitor…incoming…texts” requires you to use an undocumented capability of Android. While probably
android.provider.Telephonywill not be going away, you just need to be aware of the risk involved.