Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get Android permission dynamically

I'm wondering if it's possible to get Android permission dynamically without using AndroidManifest just with some codes, because I've some OSGi bundles running on Android and without Android permission they are restricted in functionality.


Thanks for your answers, yes it complicates the user experience and it's also dangerous for the user if that mechanism is provided

like image 270
Aghiles Adjaz Avatar asked Jan 29 '11 18:01

Aghiles Adjaz


People also ask

How do I get runtime permission on Android?

checkSelfPermission(String perm); It returns an integer value of PERMISSION_GRANTED or PERMISSION_DENIED. Note: If a user declines a permission that is critical in the app, then shouldShowRequestPermissionRationale(String permission); is used to describe the user the need for the permission.

How do I set permissions in Android programmatically?

You need to declare the permissions in the manifest file first before you request for them programmatically. refer this for more information. declaring the permission in the manifest file is static type declaration by which your os know what kind of permission your app might require.


4 Answers

No this is not possible.

You can't alter the contents of an already installed APK. It would be very dangerous to allow such a behavior anyway as the whole permissions system is meant to allow the user to first read what permissions an Application requires so he can judge if it is ok or not.

like image 128
Octavian A. Damiean Avatar answered Nov 05 '22 12:11

Octavian A. Damiean


No, sorry, you must request all permissions via the AndroidManifest.xml file.

like image 34
CommonsWare Avatar answered Nov 05 '22 14:11

CommonsWare


Yes, i found this line in http://developer.android.com/guide/topics/security/security.html:

Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.

like image 29
diyism Avatar answered Nov 05 '22 13:11

diyism


Guys now from Android 6.0 Marshmellow onward, you can ask users at runtime to allow permissions dynamically, I found of it, have a look at this link. I hope it will help you getting idea. a good tutorial

like image 40
Naveed Ahmad Avatar answered Nov 05 '22 12:11

Naveed Ahmad