问题
While working on an Android application I am required to grant permission for reading/writing for contacts and profile. I found Android manifest file have possible permissions like,
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.WRITE_PROFILE"/>
And I am able to show request runtime permission for Contacts i.e.,
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
However when I put below code, It says READ_PROFILE
is not found.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_PROFILE},
MY_PERMISSIONS_REQUEST_READ_PROFILE);
How can I request runtime permission for reading/writing profile. I am using,
Intent intent = new Intent(Intent.ACTION_EDIT, ContactsContract.Profile.CONTENT_URI);
MainActivity.this.startActivity(intent);
But after editing profile info, when I save it does not update the profile rather shows a toast like,
Nothing to save. Contact discarded
Is it a permission issue? How can I update profile info successfully?
回答1:
READ_PROFILE
permission was removed on API 23 as stated here:
https://developer.android.com/sdk/api_diff/23/changes.html
Use GET_ACCOUNTS
instead.
https://developer.android.com/guide/topics/permissions/requesting.html#perm-groups
来源:https://stackoverflow.com/questions/56220207/manifest-permission-read-profile-not-found