1

I am developing an app, there I am overriding and creating the folders in the OnRegisterApplicationDependencies method. As application runs before any other activities. I wanted to ask the permission in the Application Level. Is it possible or is there a work around other than moving the Create folder part to an Activity.

Thanks in Advance

Amalan Dhananjayan
  • 2,277
  • 1
  • 34
  • 47
  • 1
    I use `requestPermissions(new String[]{Manifest.permission.GET_ACCOUNTS},REQUEST_CODE);` in fragment, so I can use `onRequestPermissionsResult` in that fragment too. Again, I use `ActivityCompat.requestPermissions` in Activity and `requestPermissions` if I want to ask in fragment. Just an example. – K.Sopheak Oct 11 '16 at 04:06

1 Answers1

0

You have to ask for the permission in an activity. You could use a dialog activity to request the permission. https://developer.android.com/reference/android/support/v4/app/ActivityCompat.html#requestPermissions(android.app.Activity, java.lang.String[], int)

You can check for permissions and see if you have them in the application class, but if you don't have them you have to request them from an activity.

JLamkin
  • 721
  • 6
  • 17
  • Thanks for the Answer, I have written my own article on how to ask permission in Activity level. What I am asking here is a possible way to ask Permission in Application level. You can have an Application class which extends 'Application' for your app, which fires before any other activities. – Amalan Dhananjayan Oct 11 '16 at 04:03
  • 1
    Right, I am saying you can't. You would have to check if you already have the permission. If not show some activity to get the permission and then close it. http://stackoverflow.com/questions/33867088/request-location-permissions-from-a-service-android-m – JLamkin Oct 11 '16 at 04:05