android - How to know if MediaScanner is enabled? -
i don't mediascanner android system , how implemented, battery consumption, card not reachable, etc, made directory based image viewer. know how disable (enable) scanner console this:
su & pm disable (enable) com.android.providers.media/com.android.providers.media.mediascannerreceiver
now, want java code of viewer. of course can runtime.getruntime().exec(...)
, have questions:
1) there way of doing without runtime.getruntime().exec()
?
2) how can know if mediascannerreceiver
enabled or disabled? googled , couldn't find anwser. mediascannerconnection
not seem control this. actually, don't know pm
does...
3) possible without root access?
thanks!
part 2). main question, , solution:
componentname sc = new componentname("com.android.providers.media", "com.android.providers.media.mediascannerreceiver"); int isenabled = getpackagemanager().getcomponentenabledsetting(sc); if (isenabled == packagemanager.component_enabled_state_enabled) { ... }
part 1). way be:
componentname sc = new componentname("com.android.providers.media", "com.android.providers.media.mediascannerreceiver"); getpackagemanager().setcomponentenabledsetting(sc, packagemanager.component_enabled_state_disabled, 0);
problem not work (fatal error java.lang.securityexception: permission denial: attempt change component state pid=23632, uid=10133, package uid=10081
), since system package. due part 3:
part 3) not root access necessary, can't done in java code through api security reasons: api not allow it. seems me runtime.getruntime().exec("su & pm ...")
way.
Comments
Post a Comment