'Monitor reading access to contacts ANDROID without rooting of device
There is a way to monitor reading access to contacts? I tried this experiment: I developed an application that reads contacts subsequentially i ran it. After that i analyzed the logs using adb logcat -v -b all but i didn't discover useful information that allow me to detect the access.
I show you the core operations performed in MainActivity.kt
val contacts: Cursor? = contentResolver.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
null,
null,
null)
while (contacts!!.moveToNext()) {
// Get the current contact name
columnIndex=contacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY)
name= contacts.getString(columnIndex)
columnIndex=contacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
// Get the current contact phone number
phoneNumber= contacts.getString(columnIndex)
// Display the contact to text view
System.out.println(name+" "+phoneNumber+"\n")
}
contacts.close()
Obviously, i added the permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
