Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have much bigger problems than that.</p> <blockquote> <p>i want to listen for changes on SMS Database.</p> </blockquote> <p>There is no "SMS database", or even an SMS content provider, in the Android SDK. Attempting to access the private proprietary undocumented not-to-be-touched SMS application contents will break on some devices, will break in future versions of Android, will not work with third-party SMS applications, and is generally a bad idea.</p> <blockquote> <p>The BroadcastReceiver starts a temporary Service which registers the ContentObserver.</p> </blockquote> <p>There is no such thing as a temporary <code>Service</code> which registers a <code>ContentObserver</code>.</p> <p>It might be that the <code>Service</code> is not temporary, so your <code>ContentObserver</code> remains registered and your <code>Service</code> is not shut down. This would occur, for example, if your <code>BroadcastReceiver</code> called <code>startService()</code> and your <code>Service</code> does not call <code>stopSelf()</code> (e.g., it is not an <code>IntentService</code>). This is not great, because you are now tying up a process. But, if you can convince your users that it is OK that you are tying up a process, this is the best answer, and your activity can just (re-)start the service when the activity starts up, to ensure that the <code>ContentObserver</code> is registered.</p> <p>It might be that your <code>ContentObserver</code> is not registered long, because the temporary <code>Service</code> unregisters it right away when the <code>Service</code> is shut down, and the Service is shut down right away. This is great from a memory consumption standpoint, but it probably isn't that effective for your goals.</p> <p>Or, it might be that you are leaking memory, because you register the <code>ContentObserver</code> and shut down the <code>Service</code> without unregistering the <code>ContentObserver</code>. This is horrible, because the only way the <code>ContentObserver</code> will ever get cleaned up is if Android terminates the process. Moreover, it will do this whenever it feels like, because as far as it is concerned, you aren't using the process anymore, despite the thread and <code>ContentObserver</code> and <code>Service</code> you leaked. This will result in unreliable code at best.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload