I see the Usage,but I used this lib happened something strange.
static void onCreateWithCheck(UploadImageActivity target, Bundle savedInstanceState) {
if (PermissionUtils.hasSelfPermissions(target, PERMISSION_ONCREATE)) {
target.onCreate(savedInstanceState);
} else {
PENDING_ONCREATE = new OnCreatePermissionRequest(target, savedInstanceState);
if (PermissionUtils.shouldShowRequestPermissionRationale(target, PERMISSION_ONCREATE)) {
target.showRationaleForCamera(PENDING_ONCREATE);
} else {
ActivityCompat.requestPermissions(target, PERMISSION_ONCREATE, REQUEST_ONCREATE);
}
}
}
This method I don't know how to use because it has second parameter.It don't like as Usage,and it don't delegate the class like the demo.
Do you add @NeedsPermission to onCreate(Bundle) method?
Yes.
@Alex-ZHOU Don't add an annotation to onCreate. You should separate exact process to a method.
I would advise against annotating something like onCreate, since you aren't in control of calling it yourself - the framework is. Therefore, you would have to extract your permission-protected code out of the onCreate and into another method, then annotate _that_ one.
Thx contributors!
Thanks you very much for finish my question and give me suggestion.
Most helpful comment
Thanks you very much for finish my question and give me suggestion.