How to take CLEAR_APP_CACHE permission in Android Marshmallow at runtime?

后端 未结 3 1117
耶瑟儿~
耶瑟儿~ 2021-01-18 12:12

Code:

void clearCache() {

    if (mClearCacheObserver == null) {
        mClearCacheObserver = new CachePackageDataObserver();
    }         


        
3条回答
  •  天命终不由人
    2021-01-18 12:17

    From Android M -> CLEAR_APP_CACHE, Protection level: system|signature

    Android 6.0 does not change the behavior of normal permissions (all non-dangerous permissions including normal, system, and signature permissions).

    So it is not possible to ask for that permission in runtime. To be more precise

    A signature|system permission, meaning that it can only be held by apps that are signed with the firmware's signing key or are installed on the system partition (e.g., by a rooted device user). From this stackoverflow Q/A.

    Docs: https://source.android.com/devices/tech/config/runtime_perms.html#affected-permissions

提交回复
热议问题