String[] for the annotation since it's a dealbreaker for Kotlin. Curly braces = lambda in Kotlin/**
* Register some methods which permissions are needed.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface NeedsPermission {
Array<String> value();
int maxSdkVersion() default 0;
}
or similar.
/**
* Register some methods which permissions are needed.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface NeedsPermission {
String[] value();
int maxSdkVersion() default 0;
}
you can use as below
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
fun onClickImageShare() {
}
@cuichanghao This will not trigger proper helper methods callers..
OnShowRationale or OnPermissionDenied or OnNeverAskAgain callers are not generated for a multiple declared NeedsPermission function
Sorry I haven't understood the problem. The reason we use Java for annotation is we support both Java and Kotlin for now. Does that makes sense?
Let me close the issue since there's only an inadequate info.
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_SETTINGS)
fun ringtoneApply(){
Using this in kotlin throws Error:
e: [kapt] An exception occurred: permissions.dispatcher.processor.exception.MixPermissionTypeException: Method 'ringtoneApply()' defines 'android.permission.WRITE_SETTINGS' with other permissions at the same time.
WRITE_SETTINGS and SYSTEM_ALERT_WINDOW are special cases that cannot be part of the "ordinary permission flow", because you need to redirect the user to the device settings for these permissions. That's why we raise that exception when you mix them with "normal" permission requests.
See also this reference on the Android docs.
Most helpful comment
WRITE_SETTINGSandSYSTEM_ALERT_WINDOWare special cases that cannot be part of the "ordinary permission flow", because you need to redirect the user to the device settings for these permissions. That's why we raise that exception when you mix them with "normal" permission requests.See also this reference on the Android docs.