How to ask for Identity permission in android? - android

Please let me know what is identity permissions? And how to implement from code this kind of permission?
II have already implement contacts read and other runtime permission but unable to find anything about identity permission.

GET_ACCOUNTS was previously in the Identity permission group.
It moved to the Contacts permission group in Android 6.
https://developer.android.com/reference/android/Manifest.permission.html#GET_ACCOUNTS
Android 6.0 permission.GET_ACCOUNTS

Identity – With this permission the app can find accounts on the device, see and modify the owner’s contact card and add or remove contacts from the device. The permission **group CONTACTS deals with the user’s contacts while ACCOUNT_MANAGER deals with the user’s accounts.**
<uses-permission android:name="android.permission-group.CONTACTS"/>
<uses-permission android:name="android.permission.ACCOUNT_MANAGER"/>
At code level one can set permission by using **https://developer.android.com/training/permissions/requesting.html**
First check
// Assume thisActivity is the current activity
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.group.CONTACTS);

Related

MAUI app under Android hot to give write permission to BlazorWebView

I'm developing a MAUI Blazor app that should run under windows and android
On Android I get an error from a component that tries to write on the clipboard
blazor.webview.js:1 Write permission denied.
Reading this doc I cannot figure out where and how to call the BlazorWebViewInizializing event to allow this permission
Or should I do something also in the AndroidManifest.xml?
Thanks
For this, you can check document Permissions.
In android, Permissions must have the matching attributes set in the Android Manifest file. Permission status defaults to Denied.
Above article describes how you can use the .NET Multi-platform App UI (.NET MAUI) Permissions class. This class allows you to check and request permissions at run-time. The Permissions type is available in the Microsoft.Maui.ApplicationModel namespace.
Checking permissions:
To check the current status of a permission, use the Permissions.CheckStatusAsync method along with the specific permission to get the status for. The following example checks the status of the LocationWhenInUse permission:
PermissionStatus status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
Requesting permissions:
To request a permission from the users, use the Permissions.RequestAsync method along with the specific permission to request. If the user previously granted permission, and hasn't revoked it, then this method will return Granted without showing a dialog to the user. The following example requests the LocationWhenInUse permission:
PermissionStatus status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
For more information, you can check document Permissions.

Save in Contacts works in Android 10 but not in Android 11

Am facing some weird issue I have an android app that allows users to save the profile details in Contacts like Name, phone, email, this functionality is working in Android 10 but not in Android 11. In Android 11 am able to see the contacts saved in the Phone App contacts page but this not reflecting in Contacts App. Are there any extra permissions or settings we need in Android 11 to get this work?
Contact Saved in phone app contacts page
But not reflecting in the Contacts App
In Android 11, the READ_PHONE_NUMBERS permission replaces the READ_PHONE_STATE permission for reading contact info.
See also: Permission updates in Android 11
Android 11 changes the phone-related permission that your app uses when reading phone numbers.
If your app targets Android 11 or higher and needs to access the phone number APIs shown in the following list, you must request the READ_PHONE_NUMBERS permission, instead of the READ_PHONE_STATE permission.
The getLine1Number() method in both the TelephonyManager class and the TelecomManager class.
The unsupported getMsisdn() method in the TelephonyManager class.
If your app declares READ_PHONE_STATE to call methods other than the ones in the previous list, you can continue to request READ_PHONE_STATE across all Android versions. If you use the READ_PHONE_STATE permission only for the methods in the previous list, however, update your manifest file as follows:
Change your declaration of READ_PHONE_STATE so that your app uses the permission only on Android 10 (API level 29) and lower.
Add the READ_PHONE_NUMBERS permission.

Requesting READ_PROFILE permission at runtime

According to the Android documentation (https://developer.android.com/reference/android/provider/ContactsContract.Profile.html), I need to request the android.permission.READ_PROFILE permission to read the user's profile information.
However, when I attempt to create runtime permission request, there is no Manifest.permission.READ_PROFILE I can use. Do I just use the Manifest.permission.READ_CONTACTS permission instead?
Note: The AndroidManifest.xml file can find the permission just fine:
<uses-permission android:name="android.permission.READ_PROFILE" />
READ_PROFILE permission was removed on API 23 as you can see here
https://developer.android.com/sdk/api_diff/23/changes.html
You should ask for GET_ACCOUNTS, or any of the permissions belonging to the CONTACTS group
https://developer.android.com/guide/topics/permissions/requesting.html#perm-groups

android registerContentObserver for Contacts requires READ_CONTACTS permission

I just discovered that, during app initialization my registerContentObserver for Contacts requires READ_CONTACTS permission. Obviously, for a new user on Android 6 and later, this permission won't yet be granted.
It seems to me it would be sufficient to ignore the permission during registration and check permission when the app listener tries to access contacts - which I'm sure it already does.
Same for Calendar.
Should I make an Android change request - why is this coding "penalty" being imposed?

Android 6.0 permission.GET_ACCOUNTS

I'm using this to get permission:
if (ContextCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.GET_ACCOUNTS)) {
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSIONS_REQUEST_GET_ACCOUNTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
But the pop up dialog for permission asks user for access Contacts!?!?
In pre 6.0 in Play Store with
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
request is named Identity and explains I need it to get device account.
That is because of Permission Groups. Basically, permissions are placed under different groups and all permissions from that group would be granted if one of them is granted.
Eg. Under "Contacts" , there is write/read contacts and get accounts, so when you ask for any of those, the popup asks for Contacts permissions.
Read through: Everything every Android Developer must know about new Android's Runtime Permission
EDIT 1
Just thought i'l add the related(not to get accounts but permissions and groups) Oreo update info:
source: https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp
Prior to Android 8.0 (API level 26), if an app requested a permission
at runtime and the permission was granted, the system also incorrectly
granted the app the rest of the permissions that belonged to the same
permission group, and that were registered in the manifest.
For apps targeting Android 8.0, this behavior has been corrected. The
app is granted only the permissions it has explicitly requested.
However, once the user grants a permission to the app, all subsequent
requests for permissions in that permission group are automatically
granted.
GET_ACCOUNTS was moved into the CONTACTS permission group in Android 6.0. While the API has us provide permissions, the user (for Android 6.0 at least) is prompted for permission groups. Hence, the user will be given the same prompt for GET_ACCOUNTS as the user would get for READ_CONTACTS or WRITE_CONTACTS.
Fortunately this will change in Android N
http://developer.android.com/preview/behavior-changes.html#perm
The GET_ACCOUNTS permission is now deprecated. The system ignores this
permission for apps that target Android N.
In Marshmallow all dangerous permissions belong to permission groups.
The permission android.permission.GET_ACCOUNTS belongs to CONTACTS group
You can find more information about dangerous permission and their groups here:
https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
I got your question wrong first. On this page http://developer.android.com/guide/topics/security/permissions.html#perm-groups, your can see that GET_ACCOUNTS refers to the permission group contacts. Because of that your are prompted for contact permission.
If your using the GET_ACCOUNTS permission to ask the user to select a particular account type on the device(Google in my case), you can use the AccountPicker class which doesn't require any special permissions
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE},
false, null, null, null, null);
try {
startActivityForResult(intent, REQUEST_ACCOUNT_PICKER);
} catch (ActivityNotFoundException e) {
// This device may not have Google Play Services installed.
}
You'll need Google Play services auth in your gradle dependencies
implementation com.google.android.gms:play-services-auth:16.0.1
This avoids the Contacts permission popup for me

Categories

Resources