You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android-Kotlin:生物识别登录成功后跳转Google Docs链接

修改方案

要实现点击登录成功文本跳转指定Google Docs链接,可按以下方式修改代码:

完整修改后的代码

import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.animation.AnimatedVisibility

@Composable
fun TextAuthenticationResult(visibilityState: Boolean) {
    val context = LocalContext.current
    // 替换为你的Google Docs共享链接
    val targetUrl = "https://docs.google.com/your-shared-document-path"

    AnimatedVisibility(visible = visibilityState) {
        SelectionContainer { // 可选:保留文本复制功能
            Text(
                text = "Authentication success",
                textAlign = TextAlign.Center,
                modifier = Modifier
                    .padding(5.dp)
                    .clickable {
                        // 构建打开链接的Intent并启动
                        val intent = Intent(Intent.ACTION_VIEW, Uri.parse(targetUrl))
                        context.startActivity(intent)
                    },
                style = MaterialTheme.typography.bodyLarge.copy(
                    textDecoration = TextDecoration.Underline // 添加下划线提示可点击
                ),
                color = Color("#9ccc65".toColorInt())
            )
        }
        Spacer(modifier = Modifier.padding(bottom = 10.dp))
    }
}

关键改动说明

  • 通过LocalContext.current获取当前上下文,用于启动系统浏览器打开链接
  • 给Modifier添加clickable修饰符,点击时触发打开链接的逻辑
  • 给文本添加下划线样式,明确提示用户该文本可点击(可选但提升交互体验)
  • 用SelectionContainer包裹文本,确保用户可复制文本的同时不影响点击功能(可选)

注意:请确保你的Google Docs链接设置为公开可访问,否则用户打开时会遇到权限限制。

内容的提问来源于stack exchange,提问作者Shodgson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 13:59:54