* Gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.pedroSG94:AutoPermissions:1.0.3'
}
* MainActivity.java
public class MainActivity extends AppCompatActivity implements AutoPermissionsListener { // AutoPermissions
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AutoPermissions.Companion.loadAllPermissions(this, 101);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
AutoPermissions.Companion.parsePermissions(this, requestCode, permissions, this);
}
@Override
public void onDenied(int requestCode, String[] permissions) {
showToast("permissions denied : " + permissions.length);
}
@Override
public void onGranted(int requestCode, String[] permissions) {
showToast("permissions granted : " + permissions.length);
}
public void showToast(String data) {
Toast.makeText(this, data, Toast.LENGTH_LONG).show();
}
}
'android' 카테고리의 다른 글
버튼 사용자정의 사용 (0) | 2020.02.03 |
---|---|
NicePatch(png 이미지 확대시) (0) | 2020.02.03 |
SMS Receiver (0) | 2020.02.03 |
Service 사용법 (0) | 2020.02.02 |
Pager 사용법 (0) | 2020.02.02 |