NOTE: This question IS NOT for customizing the text in a permission request dialog (shouldShowRequestPermissionRationale() mentioned in OP).
Are the message strings displayed when calling requestPermissions() standard, or vendor specific? Are these strings accessible for reuse?
In OnRequestPermissionsResult(), if the user denies Android.Manifest.Permission.WriteExternalStorage, I would like to show a dialog saying "<app-name> requires " + "Allow <app-name> to access photos, media, and files on your device" (or something to that effect), instead of writing a different message like "SD-Card write access required to continue." (which is something more suited shouldShowRequestPermissionRationale()).
I'd prefer the messages match to avoid confusion, so that when the user is re-prompted they know exactly what permissions are required to allow.
Here is an example of my usage of OnRequestPermissionsResult
Are the message strings displayed when calling requestPermissions() standard, or vendor specific?
Anything can be changed by device manufacturers. Even for the subset of devices that are part of the Google Play ecosystem, message text like this could be changed.
Are these strings accessible for reuse?
They appear to come from the description of the <permission-group> to which your permission belongs. Presumably you can use PackageManager and PermissionGroupInfo to get the values at runtime.
update(samusarin):
PermissionGroupInfo pgi = this.PackageManager.GetPermissionGroupInfo(Android.Manifest.Permission_group.Storage, PackageInfoFlags.Permissions);
string desc = pgi.LoadDescription(PackageManager);
Related
I am using Google Cloud Messaging and to manage the users devices server side im storing the GCM Registration ID and the Users Device ID in my Database. You can get the Device ID like that:
public static String getDeviceID(Context context) {
final String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
if (deviceId != null) {
return deviceId;
} else {
return android.os.Build.SERIAL;
}
}
Since Android 6.0 i have a problem with that because to read the Devices ID you need to use the dangerous permission android.permission.READ_PHONE_STATE. So when the user uses my App and the automatic background process to register for the GCM Service he get's automatically asked to grant permission for make and manage phone calls which, in my opinion, is totally confusing for the user. He would not understand why the app needs to make and manage phone calls and i also dont want another dialog box to explain the user why the app needs this permission. It would make the app complicated and somehow frustrating for some users.
I want to get around this so i have to ask if there is any alternative way to uniquly identify a users device without needing any dangerous permission.
It has to fullfill following requirements:
It must be unique
It must be always the same id for a single device also after uninstalling and reinstalling the app
The reason for that is simple:
The user can have multiple devices
There can be multiple users on one device
Ofcourse i could just set my target SDK to < 23 but some day you have to update your system anyway when you need new features from the 6.0 or greater API.
I also dont want to give the user the freedom of decision for that purpose because if the user does not grant the READ_PHONE_STATE permission it would mess up the whole live update, messaging and synchronization system of the App.
Is there a way to choose which order the user is prompted for permissions in Android Marshmellow's new permissions dialog?
When the user launches the camera in my app, I'm prompting for:
Manifest.permission.CAMERA
Manifest.permission.WRITE_EXTERNAL_STORAGE
Manifest.permission.RECORD_AUDIO
Because it makes the most sense (e.g. open camera, app requests camera permissions), I want the permissions to be requested in that order as well. But they aren't requested in that way - the Permissions dialog seems to just ignore the order I have in the String array.
Code below, using the EasyPermissions library, but the same thing happens without the EasyPermissions library.
ArrayList<String> permissionsToRequest = new ArrayList<String>();
permissionsToRequest.add(Manifest.permission.CAMERA);
permissionsToRequest.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
permissionsToRequest.add(Manifest.permission.RECORD_AUDIO);
EasyPermissions.requestPermissions(
this,
"To take pictures & record video, we need access to your device's camera & storage. Allow?",
R.string.acceptPermission, R.string.declinePermission,
RequestConstants.REQUEST_CAMERA_PERMISSIONS,
permissionsToRequest.toArray(new String[0])
);
Regardless of how I order the permissions in permissionsToRequest, the user is prompted in the same order (Audio, Storage, Camera), which in my opinion is the least intuitive order. Any way to fix this?
Although there isn't a clear way to define the order of permission, I found that it is somehow related to the order defined in the AndroidManifest.xml and in the array passed in Activity.requestPermissions(String[] permissions, String requestCode)
In a device, the order of the permission array was the order it showed in the screen. In a different device, the order defined in the manifest prevailed.
Hope this helps.
In marshmallow's runtime permission, user can choose "never ask again" in permission requests. In this case, we have to redirect user to app settings to let them enable the permissions for the app. Also, Android permissions are group based, it will be very handy to display names of the permission groups that the app needs before we send the user to the settings.
I've seen the strings in android.Manifest such as "android.permission-group.LOCATION". Is it possible to get the permission group names programmatically?
getPermissionGroupInfo() on PackageManager returns a PermissionGroupInfo for that group name (android.permission-group.LOCATION). On that, call loadLabel(), supplying the PackageManager as input, to get the human-readable name of the permission group. This should be localized for the user's chosen device locale.
I had an idea for an android security app, but looking over the Device Administrator api documentation, I can't see if it's even possible. I want the app to be able to set the password used to unlock the phone. It would need to set the password without input or confirmation from the user.
Anyone know if it's even possible, and if so, is there any documentation for it?
Found what I was looking for, it can be done per
http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#resetPassword(java.lang.String, int)
public boolean resetPassword (String password, int flags)
Added in API level 8
Force a new device unlock password (the password needed to access the entire device, not for individual accounts) on the user. This takes effect immediately. The given password must be sufficient for the current password quality and length constraints as returned by getPasswordQuality(ComponentName) and getPasswordMinimumLength(ComponentName); if it does not meet these constraints, then it will be rejected and false returned. Note that the password may be a stronger quality (containing alphanumeric characters when the requested quality is only numeric), in which case the currently active quality will be increased to match.
The calling device admin must have requested USES_POLICY_RESET_PASSWORD to be able to call this method; if it has not, a security exception will be thrown.
Parameters
password The new password for the user.
flags May be 0 or RESET_PASSWORD_REQUIRE_ENTRY.
Returns
Returns true if the password was applied, or false if it is not acceptable for the current constraints.
I dont think it is possible at all, since every app runs in kind of a sandbox to forbid for example malware executing something like you mentioned.
Looking at this: http://developer.android.com/guide/topics/admin/device-admin.html
There seems to be a way for an app to ask for a password:
Set a password for the device
This code displays a user interface prompting the user to set a password:
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
However, I'm not sure you can do this from within the app, silently without any user input. Also, Device Administration apps does not seem to be a normal apps and seem to be intended for corporations/institutions.
When my app upload to android market,Upload assets have a warnig message about this:
This apk requests 1 permissions that users will be warned about
android.permission.INTERNET
I check the app of manifest.xml,I'm sure there are manifest.xml to join the line
uses-permission android:name="android.permission.INTERNET
so...Why are there warning message about android.permission.INTERNET?
And another question,the Upload assets of "Localized to" appear unknown,
how to set this field about "Localized to"?
thanks~
Your application end users will be notified before installation the application have full access to Internet, something like this (there are 3 permissions, in your case only "Network communication" will appear):
you need to add localized strings first and market will automatically recognizes them.
see developer.android.com reference