Is it possible to set android app permission dynamically in java, usually it is set in AndroidManifest.xml. But what I want to do is giving my users a choice of what permissions they want my app to give.
thanks in advance!
No, it is not currently possible. Up through Android Lollipop, permissions must be explicitly requested in the app's manifest and must be collectively all granted or denied (not installing the app) by the user at install time.
Android M, however, is changing this. As of Android M, permissions will be granted at runtime instead of at install time, allowing you to give users more control over which permissions they allow your app to use.
See the Android M runtime permissions documentation for more detail.
At the moment it's not possible http://developer.android.com/guide/topics/security/permissions.html
Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.
Things may change in new android M release
Nope. App's permissions are declared in AndroidManifest.xml, which is used to tell Android system what permissions are required. App installer will show all permissions to help user judge the app is good or bad.
Thing about that if an malicious app require nothing at install-time and require camera permission at run-time dynamically
It would be against Android policy . The application has or not has the permissions for doing something . It can be a security problem if you can think of it.
It is possible no issue but in mid of app if not get then chances of getting crash in your app...
Related
I have an security App (App Locker) that uses this permission:
android.permission.GET_TASKS
In android Lollipop this permission is deprecated and i want that my app works in +21 API.
Can anyone guide me how?
Thnx :)
There is reason why it is deprecated.
The protection Level of android.permission.GET_TASKS has been elevated to signatureOrSystem.
There is no easy and unharmful solution for that.
As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see getAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.
http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int,%20int)
I saw a new permission REAL_GET_TASKS that is said to be used instead of GET_TASKS:
New version of GET_TASKS that apps can request, since GET_TASKS doesn't really give access to task information. We need this new one because there are many existing apps that use add libraries and such that have validation code to ensure the app has requested the GET_TASKS permission by seeing if it has been granted the permission... if it hasn't, it kills the app
with a message about being upset. So we need to have it continue to look like the app is getting that permission, even though it will never be checked, and new privileged apps can now request this one for real access.
See the Android code difference at: https://android.googlesource.com/platform/frameworks/base/+/2d7576b%5E!/
I am currently looking to develop an interface debug tool for Android which would display some system information overlaid on top of whatever app is running underneath. I've look at many different resources online and followed the basic procedure of setting my application to TYPE_APPLICATION_OVERLAY defining the permissions required in my manifest with android.permission.SYSTEM_ALERT_WINDOW, however, when trying to run the application the process, it crashes with the error FATAL EXCEPTION ... Unable to add window android.view.ViewRootImpl$W... -- permission denied for window type 2038.
I tried further investigating what could be causing the problem, and I managed to find out that since a certain version, Android will require for users to explicitly set permissions for apps to draw over other apps via Settings.ACTION_MANAGE_OVERLAY_PERMISSION, however, even after enabling permissions to draw over other apps, the process still resulted in the same error.
I currently have my app setup to check whether draw-over permissions have been granted, and asks the user to set it if not. Once it confirms permissions are enabled by the user, it calls the service where I attempt to create an overlaying view.
I'm relatively new to Android development so I would appreciate any ideas or guidance!
Update: Managed to get it working by setting the window's LayoutParam to use TYPE_PHONE instead of TYPE_APPLICATION_OVERLAY. This is working for Android N, however it may be good to note that this method is deprecated for Android O+
Add this permission in your manifest.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Is it possible to disable requesting permissions at runtime android 6 and make it work normally from AndroidManifest?
I.e. when you install the app it requests permissions like it was on previous versions of android?
There is a simple solution:
Change targetSdkVersion inside application build.gradle to 22.
Then all application permission are granted during installation.
However, this won't prevent the user from going to phone settings and manually turning them off. Your app will then crash.
Yes It is possible
In your module gradle file Change targetsdk version
targetSdkVersion 22
Not this will only work if you havn't upload it on play store with targetsdk as 23.
Developers abused permissions in android by requiring nearly everything. This rendered the whole permission management system nearly useless because it is really hard to find an application which requires only permissions which it really needs for it's functioning. With regret users had to grant permissions which they do not want to grant. So a little of tyranny was needed to revive the system. You must request every permission separately now and you must somehow handle denial of some of the permissions. This is the only correct way.
So as not to break all existing applications there is a compatibility mode. If you build with targetSdkVersion 22 then you get old behaviour. But you also do not get all shiny new features. So you will not be able to live with 22'nd SDK forever and you will have to accept new rules.
I want to develop an application for android to:
List installed applications in the phone.
Show a list of permissions that are granted for each app.
Have the ability to disable any permission granted to a specific app or enable it later on.
Till now I have done the first two points. I searched the web to know how to modify permissions but I couldn't find anything useful.
So can anybody give me a clue on how to implement this ? Because I think it is doable since there some apps that can modify permissions (e.g. Permission Manager).
There are various apps in the Play Store that call themselves Permission Manager so I'm not sure which one you have looked at.
At least one of them works by pulling the installed app apart, and reforming it with a changed AndroidManifest file (and since they don't have access to the original private key, a new signature). To run the reformed app you have to uninstall the old one, and install the new one, which has 2 significant downsides
all the data of the old app is lost
since you now have an effective pirate version of the app, the app will no longer update with new versions from the Play Store.
Other apps that claim to manage app permissions simply expose the hidden App Ops permission screen in Android 4.3, and Google removed this from the later Android 4.4 update.
We have a AutoCompleteTextView which is able to read from the users-contact-data as a convenience. However some users complain about the "READ_CONTACT" Permission the App is enforcing at installation. Is there any Way to let the user Choose to grant this permission and use this feature, or deny it and loose the feature? If it is not possible at Runtime, maybe there is some other way? Building two Apps, one with that permission and one without is not an option!
Is there any Way to let the user Choose to grant this permission and use this feature, or deny it and loose the feature?
Unfortunately, no.
If it is not possible at Runtime, maybe there is some other way? Building two Apps, one with that permission and one without is not an option!
You can build a main app without that permission, then create a plugin that holds the permission and securely interacts with the main app. This is a bit of an advanced technique. I cover it in one of my books, and here is the directory with sample projects demonstrating the host and the plugin. In my case, I am using CallLog instead of ContactsContract, though the permission (READ_CONTACTS) is the same.
I'm not too sure about this, but you could build a separate app, that requires this permission. This extra app provides a content provider. Your main app now checks if your extension app is installed and gets that data from the content provider.