How to find out which permission an android applic

2019-06-18 16:10发布

问题:

how can i find out which permissions i need to add in manifest for my applications? Actually, WHEN i need to add permission in manifest and HOW to find out my app really need to add some permissions in manifest before install it on device? is it possible to find out permissions from imported package? for example is there any way to find out we need to add "uses-permission android:name="com.android.alarm.permission.SET_ALARM" permissions in manifest because we add "import android.app.AlarmManager;" in code?

MY BIG PROBLEM IS: my apps work fine, but when users upgrade phones to new android, my apps not work, and i need to find out which permission lost from my manifest. (for example we don't need any permissions for SD card access in android 2.2, but in android 4.0 we need to add permissions in manifest). thanks in advance

回答1:

how can i find out which permissions i need to add in manifest for my applications?

Sometimes, the permissions are documented, such as in the JavaDocs for classes and methods that need those permissions.

Sometimes, the permissions are not well-documented. You find out that you need them by testing, or by running across notes about them elsewhere, such as Stack Overflow questions and answers.

On occasion, an IDE (e.g., Android Studio) or a build process (e.g., Gradle with Lint checks) will complain at compile time about a missing permission. Usually, those are for already-documented permission requirements. That being said, running a manual Lint check ("Inspect Code" in Android Studio) is a good idea before shipping an app.

HOW to find out my app really need to add some permissions in manifest before install it on device?

Testing.

is it possible to find out permissions from imported package?

Permissions are not usually tied to Java packages.

for example is there any way to find out we need to add "uses-permission android:name="com.android.alarm.permission.SET_ALARM" permissions in manifest because we add "import android.app.AlarmManager;" in code?

You do not need to use SET_ALARM because you are importing AlarmManager. No import statement requires a permission.

but when users upgrade phones to new android, my apps not work

Quickly test your apps on new versions of Android as those versions are released. When you are given access to developer previews — as developers were prior to Android 5.0 and 6.0 — test on those developer previews.



回答2:

AndroidStudio logcat gives a warning when using the aplication in develop mode, it actually asks you if you added the permission into the manifest when it tries to use something that needs permission and failed to work.