[英]Clear another applications cache
I´ve been reading around here about cleaning another applications cahce-memory, and I´ve also tried coding my own app. 我一直在这里阅读关于清理其他应用程序的内存,我也尝试过编写自己的应用程序。 The result I´ve got, is that with Androids current securitylayer, it´s not possible. 我得到的结果是,使用Androids当前的安全层,这是不可能的。
But, there is currently many cache-cleaner applications out there on the Market (Google Play)? 但是,目前市场上有许多缓存清理应用程序(谷歌播放)?
When I started my application which I gave the android.permission.DELETE_CACHE_FILES
permission, the LogCat printed 当我启动我的应用程序时,我给了android.permission.DELETE_CACHE_FILES
权限,LogCat打印
Not granting permission android.permission.DELETE_CACHE_FILES to package <MY_PACKAGE_NAME> (protectionLevel=3 flags=0x8be46)
After some research I found out that 3:rd party apps would not be granted permissions with protectionLevel=3
so, I encounter a java.lang.SecurityException whenever I try to delete another application cache (logically) 经过一些研究后我发现3:第一方应用程序不会被授予protectionLevel=3
权限所以,每当我尝试删除另一个应用程序缓存(逻辑上)时,我会遇到java.lang.SecurityException
My question is therefor: "How is these applications on Google Play permitted and able to delete other applications cache?" 我的问题是:“Google Play上的这些应用程序如何允许并能够删除其他应用程序缓存?”
Sorry for my bad English, not a native speaker 抱歉我的英语不好,不是母语
如果设备已植根且您的应用程序具有超级用户权限,则只能执行此操作。
Let me tell you how these apps achieve this. 让我告诉你这些应用程序如何实现这一目标。
Some android classes have methods
which are private(@hidden)
to user by default. 一些android classes have methods
默认具有对用户private(@hidden)
android classes have methods
。 We cannot access them directly . 我们无法直接访问它们 。 but you have a better approach to use Reflection
. 但是你有更好的方法来使用Reflection
。
Add permission. 添加权限。
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
And follow these answers 并按照这些答案
https://stackoverflow.com/a/17334600/3496570 https://stackoverflow.com/a/17334600/3496570
https://stackoverflow.com/a/14509140/3496570 https://stackoverflow.com/a/14509140/3496570
And don't forget to create a package
name android.content.pm
and add IPackageDataObserver.aidl to package . 并且不要忘记创建一个package
名android.content.pm
并将IPackageDataObserver.aidl添加到包中。 Then you are good to go. 然后你很高兴去。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.