简体   繁体   中英

About Android, how to prevent other apps reading my contacts

I try to write an Android app to prevent other apps reading my contacts, even these apps get the android.permission.READ_CONTACTS permission

I google a lot, but get nothing. Could anyone give me some idea about this app...

Thanks!

You can block the apps which has android.permission.READ_CONTACTS permission.You can get the list of apps which has android.permission.READ_CONTACTS permission through package manager api.

If you dont want to disable those app,you can revoke those permission using- http://androidxref.com/4.4.4_r1/xref/frameworks/base/core/java/android/app/AppOpsManager.java API through reflection.

Following is the method in ApoOpsManager.java which can be used for blocking a permission

/** @hide */ public void setMode(int code, int uid, String packageName, int mode) {

 try { mService.setMode(code, uid, packageName, mode); } catch (RemoteException e) { } 

}

To learn how to use reflection for calling internal/hidden api use: http://jhshi.me/2014/04/02/get-package-usage-statistics-in-android/.similar

This approach may not work always but ya this is the only workaround which I can think of since there are no direct apis to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM