Open onusgit opened 5 years ago
What Android version?
@onusgit I guess you're hitting the same issue as I have, and that is trying to access contacts without first checking for permissions. Check out the methods for this here https://github.com/joshuapinter/react-native-unified-contacts#can-the-user-access-contacts
if your andoid version >=6 ,you should add this in your MianActivity . You can also add it in other place but should be called to ensure the permission when application starts.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, 1);
}
}
@onusgit
if your andoid version >=6 ,you should add this in your MianActivity . You can also add it in other place but should be called to ensure the permission when application starts.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, 1); } }
@onusgit
i also have the same errors, you can tell me where exactly should i enter this code, because i entered this code in my code but i have another error
I am not access my device contact in android device.
I set Permission in AndroidManifest.xml file