Android App not asking for permissions when installing - android

I work in the IT department of my university and we work on an app that installs the correct setup for the eduroam WiFi (maybe you have heard of it).
However I have a problem running it on my own LG G4 with Android 6.0. When installing the compiled *.apk it doesn't ask for any permissions although they are set in the AndroidManifest.xml. It was working on all previous Android versions.
Is it mandatory now to ask for permissions at run time?

If your target SDK version is 23 then you need to ask for "dangerous" permissions at run time.
If this is the case then you should be able to see that no permissions have been granted if you go to Settings > Apps > "Your app" > Permissions.
If you don't want to do implement the new system yet then you can reduce your target sdk version to 22 to get the old permission system. You can still compile with sdk version 23 though.
See the documentation for more information.

if you want to request permissions at runtime you should write a special request in your app. Something like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
createPermissions();
}
public void createPermissions(){
String permission = Manifest.permission.READ_SMS;
if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){
if(!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
requestPermissions(new String[]{permission}),
SMS_PERMISSION);
}
}
}

If the user is running Android 6.0 (API level 23) or later, the user has to grant your app its permissions while they are running the app. If you confront the user with a lot of requests for permissions at once, you may overwhelm the user and cause them to quit your app. Instead, you should ask for permissions as you need them.
In some cases, one or more permissions might be absolutely essential to your app. It might make sense to ask for all of those permissions as soon as the app launches. For example, if you make a photography app, the app would need access to the device camera. When the user launches the app for the first time, they won't be surprised to be asked for permission to use the camera. But if the same app also had a feature to share photos with the user's contacts, you probably should not ask for the READ_CONTACTS permission at first launch. Instead, wait until the user tries to use the "sharing" feature and ask for the permission then.
If your app provides a tutorial, it may make sense to request the app's essential permissions at the end of the tutorial sequence.
Source/ref https://developer.android.com/training/permissions/usage-notes

Related

How to auto accept android permissions

I am developing an app for internal use and it requires some permissions like camera, internet, etc.
In order to make everyone's life easier I am investigating the possibility of auto accepting all these permissions on runtime.
The app will not be published on Play Store and it will only be used by employees on company premises and with company devices, so there is no security risk involved here.
Any ideas? Is this even possible? Hackish solutions work too, doesn't really matter as long as the goal is achieved.
If you're using targetSdkVersion>=23 your app has to request the permissions
If permissions are considered "normal" the system will immediately grant them upon app installation. Other permissions which are considered "dangerous", the user must explicitly grant your app access to them.
If you downgrade the targetSdkVersion to API level 21 , there would be no need to ask permissions , since they will granted during app installation, but still on android devices with OS versions >= 6.0 the user can go to app settings and disable them.
I don't think that you can, and this is why:
If your permission is normal permission it will be auto-granted.
If the device API level is <= 22 / targetSdkVersionis 22 or lower:
In that case, the user will be asked (by the system) in the install time to grant all the dangerous permissions for the app.
If the device API level is > 22 and targetSdkVersion is above 22:
The user will not accept dangerous permissions at install time. You must ask the user to grant access to the dangerous permissions at runtime - when you do ask your user to give access to those permissions on run time he will see system dialog that asks him to accept or decline the permissions.
I don't think that you can do what you want and I think that your best solution is to just ask the users the wanted permissions.

How to apply successfully Runtime Permissions in Android?

I want to ask for any permission to the user after installing the app.
Is it possible to request runtime permissions from current API(7.0) to API level 19 (4.4)?
I've read the documentation and I've tried a lot of examples.
Everything seems too complex and I've even seen plugins to request permissions.
The documentation provides an example usign several NuGet Packages:
https://developer.xamarin.com/samples/monodroid/android-m/RuntimePermissions/
But it only works with Android M (6.0 API level 23) and above...
This article talks about it:
https://blog.xamarin.com/requesting-runtime-permissions-in-android-marshmallow/
For example, in my case I want to check if the app have the "permission CAMERA" and if not ask for the user, something like this:
if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera) != (int)Permission.Granted) {
// Permission has never been accepted
// So, I ask the user for permission
ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, REQUEST_CAMERA);
} else {
// Permission has already been accepted previously
}
The application opens without displaying anything.
The check works but "RequestPermissions" don't ask anything to the user.
Why not show anything?
Why I need to use "ActivityCompat" if also doesn't work in versions prior to M?
Can anyone give me an example to request runtime permission from a simple code (compatible with versions prior to M)?
I got the same result as you, so did a little investigation. The trick is that you have to set permissions in 2 places.
1. In manifest
2. Request permissions in run time
As shown here https://developer.android.com/training/permissions/requesting.html
the result is different.
On all versions of Android, your app needs to declare both the normal and the dangerous permissions it needs in its app manifest, as described in Declaring Permissions. However, the effect of that declaration is different depending on the system version and your app's target SDK level:
If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.
If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.
Runtime Permissions were introduced in Android 6.0 (API 23 - Marshmallow). As such you will not be able to programmatically set up Runtime Permissions on any Android API lower than 23. The Requesting Runtime Permissions in Android Marshmallow guide you linked in your question is likely the best resource here, and the Check the SDK Version section shows the logic for checking the API level and preventing the Runtime Permissions workflows from being called on API levels prior to 23.
For previous API levels from 22 and prior you will need to add your install-time permissions in your AndroidManifest.xml as described in the Add Permissions to Android Manifest guide.
Besides setting your Permissions in Manifest.xml you can check the permission using Xamarin.Essentials: Permissions
It automatically prompt the user to Allow or Disallow the requested permissions.

Android Runtime Marshmallow Permission

Google allows the permission at run time and it allows the user to allow or deny the permission.
When user installs the app the permissions should automatically be ON, it should not be asked to user.
How can i get this functionality?
Thank you.
It is not possible. If user not allow permission then app cant access resource related to particular permission. It is done by google for security purpose.
When user installs the app the permissions should automatically be ON, it should not be asked to user.
Have a targetSdkVersion below 23. This is not a viable long-term solution, as eventually something will force your hand to have a targetSdkVersion of 23 or higher.
You cite OlaCabs as an example of the behavior that you want. OlaCabs has a targetSdkVersion of 22.
How can I set default permission in marshmallow so that if user sets off the permission manually and again when user opens the app the permission should be ON and the permissions should not be ask to user, it should be directly ON.
That is not possible. For example, with OlaCabs, after installing it but before running it, I revoked its rights to access contacts, location, phone, SMS, and storage. I then ran OlaCabs, and it crashed, because I had revoked its access to location data, and the authors of OlaCabs do not check to see whether they have permission first. OlaCabs does not magically cause those permissions to be re-granted.
It is not possible to do so on marsh mallow, as it is fully based on runtime permissions.It increases users security.Your queries are supported only to Versions below marshmallow.Try having target version as 22 and run your app.

Android Studio Debugging does not demand for permission?

A small question: I am trying to debug my App, developing in Android Studio, with my Smartphone. I have listed several uses-permission in my manifest. But when I debug the app, the smartphone does not ask me for the permission to use the permissions... will I nevertheless have access to my "uses-permission" permissions? If not, how can I debug it :D
Runtime permissions are a new thing on Android. They only work if your both Target API and the device you are using are level 23 or higher. If any of those is lower, then Runtime permissions do not work and old permission model is used. In old model, permissions are granted at install time and when you install your app via USB, you automatically accept all permissions. Still, in new permission model, you need to write code in async style, meaning that first you have to ask user for permission and supply a callback, in which you will know whether the user granted or denied specific permission. You can read more about that at officials docs.

How can I start my app with all permissions allowed on Android 6

I check if user has permission, but just wanna do that when he deny on Android Options. When he install my app, how can I set all permissions on. I saw that happens on Google I/O 2015 app.(You can turn off permission, but when you install, this permissions are already on).
Thanks!
The 2015 Google IO app targets API version 22, which means that it will not use the runtime permissions model, even if running on a device running Android 6.0 (API 23) and up. In this case, permissions are still granted at install time, but users can still go in and manually disable permissions.
If you are targeting API 23+, you must use the new runtime permissions model. No permissions will be granted to your application at install time.
I hope you speak Spanish, otherwise, use a translate tool. Android 6.0 changed the way permission works, dangerous permissions are disabled by default even if you define them in the manifest.
Check my post here, http://androidenespannol.blogspot.com/2015/11/solicitar-permisos-en-tiempo-de.html
Best regards

Categories

Resources