android - Register ContentProvider only if authority does not exist -
i'm developing custom home screen launcher. part of functionality able show unread notification badges.
instead of implementing own api this, hook onto existing standards. used 1 samsung's touchwiz launcher.
it works through contentprovider authorization com.sec.badge
. now, on samsung devices, can utilize contentobserver observe changes samsung's contentprovider , works perfectly. however, on devices without existing contentprovider (i.e. non-samsung devices) provide own contentprovider purpose. works capture inserts other apps.
however, when roll own contentprovider naturally install_failed_conflicting_provider
error when trying install on samsung devices.
i understand why happening since android wants avoid having conflicts in providers.
what want help workaround. possible somehow register contentprovider dynamically instead of declaring in androidmanifest.xml
? way, first check if authorization taken, , if go observer. otherwise, register own contentprovider , go that.
i realize might bad practice don't see other way. apps (such facebook) implement sony's badge api works through broadcasts avoids conflict, not many existing apps utilize process.
i've tried this:
contentprovider test = new samsungcontentproviderspoof(); providerinfo providerinfo = new providerinfo(); providerinfo.authority = "com.sec.badge"; providerinfo.enabled = true; providerinfo.exported = true; test.attachinfo(this, providerinfo);
but fails. guess need somehow access scheme contentresolver , register myself there, don't know how.
i hook onto existing standards
there no existing standards. few vendors have done own thing, , that's it.
the used 1 samsung's touchwiz launcher.
note mechanism undocumented (afaict) , unsupported (outside of select samsung partners).
is possible somehow register contentprovider dynamically instead of declaring in androidmanifest.xml? way, first check if authorization taken, , if go observer. otherwise, register own contentprovider , go that.
you welcome disabled (android:enabled="false"
) in manifest, conditionally enable later using packagemanager
, setcomponentenabledsetting()
. know needed either trying communicate existing provider (e.g., registering observer) , getting expected error, or interrogating packagemanager
see if provider exists.
however, not need claim samsung in terms of provider, in terms of custom permissions. that break on "l" developer preview, , going forward, much same reason ran conflicting provider. @ nowadays time, there no workaround aware of.
android android-contentprovider
No comments:
Post a Comment