한글)
PermissionGen (PermissionGen
can easily handle the permissions in the Android M.
##Download
Grab via Maven:
<dependency>
<groupId>com.lovedise</groupId>
<artifactId>permissiongen</artifactId>
<version>0.0.6</version>
</dependency>
or Gradle:
compile 'com.lovedise:permissiongen:0.0.6'
##Usage When you request permissions
PermissionGen.with(MainActivity.this)
.addRequestCode(100)
.permissions(
Manifest.permission.READ_CONTACTS,
Manifest.permission.RECEIVE_SMS,
Manifest.permission.WRITE_CONTACTS)
.request();
or
PermissionGen.needPermission(ContactFragment.this, 100,
new String[] {
Manifest.permission.READ_CONTACTS,
Manifest.permission.RECEIVE_SMS,
Manifest.permission.WRITE_CONTACTS
}
);
Override the onRequestPermissionsResult in activity or fragment and input this code.
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
PermissionGen.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
When it succeeded in obtaining permission
@PermissionSuccess(requestCode = 100)
public void doSomething(){
Toast.makeText(this, "Contact permission is granted", Toast.LENGTH_SHORT).show();
}
When it failed in obtaining permission
@PermissionFail(requestCode = 100)
public void doFailSomething(){
Toast.makeText(this, "Contact permission is not granted", t.LENGTH_SHORT).show();
}
##License
Copyright 2015 Seunghwan Kim
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.