Let the user choose to grant permission in android - java

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.

Related

how to remove the third permission option

I've already googled this question but haven't found anything yet, so I need your help. How to remove the third option of permission to the memory, because if the user accidentally clicks on it, it will be necessary to go to the settings and allow the permission to the program manually, and since in general 30-40% of users are able to do this, only one will have to reinstall the program .
As people in the comments have said, it is a system dialog and you cannot change it. If you want to help users find your app's settings you can try sending them there.
Also note that according to the docs
Starting in Android 11 (API level 30), if the user taps Deny for a specific permission more than once during your app's lifetime of installation on a device, the user doesn't see the system permissions dialog if your app requests that permission again. The user's action implies "don't ask again."
So you have to deal with permanent denials even if there isn't a dedicated button.

App crashes when depricated PERMISSION not used (KITKAT) [duplicate]

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!/

Android java set app permissions dynamically

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...

Modifying installed apps permissions (Android)

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.

How to put Android to standby programmatically?

Is it somehow possible to set Android to standby-mode programmatically ?
If you're developing your own ROM or you have a rooted phone (it's need to be checked which user is able to do this) then you should have a look to the PowerManager.goToSleep functionality. Here is a discussion about this function in the Google Groups. And here you can read about this particular permission.
http://developer.android.com/reference/android/os/PowerManager.html#goToSleep%28long%29
This is what i think you are looking for.
Don't forget to include following permission.
android.permission.DEVICE_POWER
This functionality has been removed since API level 21: https://developer.android.com/sdk/api_diff/21/changes/android.os.PowerManager.html
Like Yury also mentioned, before you were able to call powerManager.goToSleep(time), but you would have needed a rooted device or app would have needed to be signed as a system app to acquire the relevant rights.

Categories