简体   繁体   English

关于Android,如何防止其他应用读取我的联系人

[英]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 我尝试编写一个Android应用程序以防止其他应用程序读取我的联系人,即使这些应用程序也获得了android.permission.READ_CONTACTS权限

I google a lot, but get nothing. 我在Google上搜索了很多,但一无所获。 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. 您可以阻止具有android.permission.READ_CONTACTS权限的应用程序。您可以通过包管理器api获取具有android.permission.READ_CONTACTS权限的应用程序列表。

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. 如果您不想禁用这些应用程序,则可以通过反射使用http://androidxref.com/4.4.4_r1/xref/frameworks/base/core/java/android/app/AppOpsManager.java API撤消这些权限。

Following is the method in ApoOpsManager.java which can be used for blocking a permission 以下是ApoOpsManager.java中的方法,该方法可用于阻止权限

/** @hide */ public void setMode(int code, int uid, String packageName, int mode) { / ** @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 要了解如何使用反射来调用内部/隐藏的api,请使用: 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. 这种方法可能并不总是有效,但是因为没有直接的API可以执行,所以这是我能想到的唯一解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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