Norway


-  - The Android Arsenal – Permissions

library to get with a simple line of code

Compile

To use this library in your project with gradle add this to your build.gradle:

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  compile 'com.github.pedroSG94:AutoPermissions:1.0.'
}

Use example

Load all app permissions

Call library in code to pop up permissions:

Java:

AutoPermissions.Companion.loadAllPermissions(activity, 1);

Kotlin:

AutoPermissions.loadAllPermissions(activity, 1)

Load activity permissions

Select permissions to load in manifest with metadata activity:

<activity
        android:name=".MainActivity"
        >
        <!--name: Must be always value of this string in the library.
        value: write all permission that you want request separates by ,-->
      <meta- android:name="@string/permissions_loader_meta_key"
          android:value="android.permission.WRITE_EXTERNAL_STORAGE, android.permission.RECORD_"/>
</activity> 

Call library in code to pop up permissions:

Java:

AutoPermissions.Companion.loadActivityPermissions(activity, 1);

Kotlin:

AutoPermissions.loadActivityPermissions(activity, 1)

Know permissions granted and permissions denied

Java:

@Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
      @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    AutoPermissions.Companion.parsePermissions(activity, requestCode, permissions, listener);
  }

Kotlin:

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    AutoPermissions.parsePermissions(activity, requestCode, permissions, listener)
}



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here