I don't know if anyone has tried this before but if you are developing an Android platform key signed persistent
app with a ContentProvider that is enabled programmatically at runtime using PackageManager#setComponentEnabledSetting(...)
you may discover that after enabling it other processes can see the provider (ContentResolver#acquireContentProviderClient(...)
returns a non-null client), but all attempts to invoke the provider hang the caller forever. It doesn't matter if you use PackageManager.DONT_KILL_APP
or not. I'm not sure if this bug exists in all versions of Android but I am seeing it in Jelly Bean 4.2 (which isn't saying much since there seem to be lots of bugs in that version).
The fix is to use PackageManager.DONT_KILL_APP
and then immediately invoke:
android.os.Process.killProcess(android.os.Process.myPid())
Then the process will be restarted and the ContentProvider that was programmatically enabled will start working properly.