Go to build.gradle(:app) and set this
minSdkVersion 21
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
dependencies {
...
implementation 'com.github.MicroProgramers:PermissionAsker:1.0.6'
}
Get Permission Dialog in just 2 lines.
- First add permissions in your AndroidManifest.xml file like this
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SMS"/>
- Make a String array of your required permissions.
- And pass the context and permissions array in to PermissionAsker.getUserPermissions(). And that's it.
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_SMS};
if (!PermissionAsker.hasPermissions(this, permissions))
{
PermissionAsker.getUserPermissions(MainActivity.this, permissions);
}
Copyright 2014 - 2021 MicroProgramers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.