是否可以创建注释来检查用户是否已通过身份验证?科特林

Is it possible to create annotation which would check if user is authenticated? Kotlin

我正在编写一个应用程序,其中的某些部分需要对用户进行身份验证。是否可以为方法编写注释,检查用户状态,并根据它调用函数或导航到登录屏幕 -> 如果登录成功,它将返回并调用该函数?像这样:

@RequiresAuth
fun commentOnTask(){
    ...
}

不,这时候我找不到如何使用注释的方法。

唯一的解决方法是使用这样的模式https://codelabs.developers.google.com/codelabs/advanced-android-kotlin-training-login-navigation/index.html?index=..%2F..index#9