In a previous post I laid out a scheme for using reflection to turn GPS on and off and update the providers.
That didn't work in the end because of this error.
W/System.err( 415): Caused by: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=415, uid=10023 is not allowed to send as package android
So how do you tell android to update the providers? Well you use a communication mechanism called an Intent.
I'm not sold on this tech idea. And android is built on it. To update the providers it just takes 2 lines of code.
Intent intent = new Intent( Intent.ACTION_PROVIDER_CHANGED );
Easy? yes. But I hate it.
Intent.ACTION_PROVIDER_CHANGED is a constant String "android.intent.action.PROVIDER_CHANGED". Intents can be any String + more data. And you'll only know if what you wrote should work is at runtime. I hate it because these things aren't checked at compile time where in my opinion it should be. If you're calling standard Intents its fairly, but other people's Intents or your own Intents make life harder because it's not always discernible in code what the strings should be and what the extra data should be.
I'm not sold on it, and it's all over the API. I have the same problem with URIs, but that will be for yet another post.