Android Runtime Marshmallow Permission - android

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.

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.

Automatically accept runtime permissions on Android Marshmalllow or above programmatically

Is there a way to automatically accept permissions on a user's mobile and without the interaction of the user with the app? When the app launches, the permissions should be accepted automatically. Please suggest me any idea/hack to do it.
Thanks
Yea its possible , For that you need change targetSdkVersion (SDK v26 or any version above to SDK v22) to targetSdkVersion SDK v22 in build.gradle , in this case it will not ask to user to grant perssion , it will take permission automatically and why its working because granting permission introduce in sdk 23 and above
Note :- it may be ask permission in OPPO phones , Vivo etc while runtime.
Sample Peoject Link :- https://github.com/kdblue/PermissionGranted
No problem if the solution is illegal but I want a way to do it
Whats this mean?
First of all this is impossible. If you are working on a technology then you have to follow its guidelines.
The second thing is if your app targets Android M or greater then you have to follow the Permission model .
If your app target is below Android M then you do not have to ask for Runtime permission, the permissions will automatically granted on installation all at once.
Note:- Starting from Android M User can manually allow/disallow the permission to any third party app . So in that case you won't get SecurityException but your feature would not work .
Conclusion:- As you see your app is going to effect anyhow whether its targets low or high, So its better to follow the Permission model and make use of Android's new version's. As Android's new versions rolls out to more and more users, apps that request permissions at the time of installation will be viewed as un-maintained or poorly written, as users will expect not to have to agree to permissions up front, which leads to bad user experience .

How to grant runtime permissions to an android application without prompting the user

I am trying to build an android application which when installed through Google Playstore should have access to the runtime permissions like SMS Access, Contacts, Location Service without asking the user for it.
I know it is possible since I have seen it happen in a couple of Android Applications on Playstore like
Kotak 811 App
Standard Chartered Banking App
Does anyone know how this can be achieved even when the phone is running Android Nougat.
How to grant runtime permissions to an android application without prompting the user
AFAIK it is not possible
Please read Run Time Permissions
I am trying to build an android application which when installed through Google Playstore should have access to the runtime permissions like SMS Access, Contacts, Location Service without asking the user for it.
than you have to make targetSdkVersion lower than 23
Does anyone know how this can be achieved even when the phone is running Android Nougat.
That is not possible and if user manually revoke the dangerous permission you app will crash
What are the disadvantages of doing targetSdkVersion lower than 23
if user manually remove permission from your app than you app get crash in android api 23 and above
EDIT
you will not be able to ship updates to your app on the Play Store starting later in 2018
Meet Google Play's target API level requirement

Android App not asking for permissions when installing

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

Which permissions do not stay upon upgrade to targetSdk 23 or Android 6?

Background
I remember that it was told (on one of Google's videos) that if the previous version of the app was updated to have targetSdk 23 on the new version, ALL permissions that were granted before - will stay granted now.
So, for example, if you installed an app with targetSdk 22, that required a permission to read from the contacts, then even after an upgrade of the app, to one with targetSdk 23, it will stay this way.
The reason is simple: the user already granted the permissions upon install.
The problem
According to what I've found, there is an exception to this rule:
If your app had the permission SYSTEM_ALERT_WINDOW , and now you upgrade to targetSdk 23, it gets revoked (reset), and you need to request it from the the user.
This behavior isn't mentioned anywhere in the docs:
http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW
http://developer.android.com/guide/topics/security/permissions.html
http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
http://developer.android.com/about/versions/marshmallow/android-6.0.html
And also not in any video I've watched.
The only thing that's mentioned about SYSTEM_ALERT_WINDOW permission, is that you need to handle them differently, using ACTION_MANAGE_OVERLAY_PERMISSION to request the permission, and Settings.canDrawOverlays(...) to check if the permission is granted
What I've tried
I tried to contact Google about this issue, and they said it's intentional:
I spoke with the development team and the behavior you're seeing is
working as intended. This is documented here:
http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW
The protection level of SYSTEM_ALERT_WINDOW was raised in Android M.
The questions
Are there other permissions that have this behavior?
What would happen, if the app had targetSdk 22/23, and there was an upgrade of the OS to Android 6 ? Will the SYSTEM_ALERT_WINDOW (or any other permission) get revoked?
Pretty sure other stuff will stay granted, but I'd like to ask anyway: What about other special permissions-like features, such as : SAF, admin, usage-access, accessibility access, notification access, ... ?
EDIT: about #2, here's the answer from Google (link here):
On OS upgrade the app should keep SYSTEM_ALERT_WINDOW. Pre-API 23 apps
have the permission by default, as opposed to API 23 Apps that are off
by default. However, there is a known bug that for API 23 Apps they
were losing SYSTEM_ALERT_WINDOW on upgrade. The recommendation for a
developer is to always check the status of SYSTEM_ALERT_WINDOW at
start and if not granted, direct the user to Settings. We will be
fixing the issue in a future release.

Categories

Resources