我正在尝试将 Google Sign in API 与我的应用程序集成。这是大学项目的一部分。我关注了以下网站:https://proandroiddev.com/google-signin-compose-a9afa67b7519
但是,当我尝试时,它根本不起作用。我已经设置了一切,甚至在 Google Cloud API 和服务、OAuth 2.0 客户端 ID 中也是如此。
@HiltViewModel
class UserSessionViewModel @Inject constructor(
application: Application,
) : ViewModel() {
private val _user: MutableStateFlow<User?> = MutableStateFlow(null)
val user: StateFlow<User?> = _user
companion object {}
init {
verifySignedInUser(application.applicationContext)
}
fun signIn(email: String, name: String){
viewModelScope.launch {
_user.value = User(
email = email,
displayName = name
)
}
}
fun signOut(){}
private fun verifySignedInUser(applicationContext: Context){
val gsa = GoogleSignIn.getLastSignedInAccount(applicationContext)
if(gsa != null){
_user.value = User( …Run Code Online (Sandbox Code Playgroud) 我阅读了有关 C++ 20 的更多内容,最近注意到了[[likely]]or[[unlikely]]属性。这似乎是一个有趣的概念,在以前的 C++ 版本中没有发现。根据官方 CPP 参考资料:
允许编译器针对以下情况进行优化:包含该语句的执行路径比不包含此类语句的任何替代执行路径的可能性更大或更小。
这到底意味着什么?
这篇博文反对使用它们,因为它看起来更像是不成熟的优化形式和一些其他细节。https://blog.aaronballman.com/2020/08/dont-use-the-likely-or-unlikely-attributes/
错误:
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/book_screen } cannot be found
Run Code Online (Sandbox Code Playgroud)
导航根主机:
animatedCompose("${Graph.BOOK}/{id}",
arguments = listOf(
navArgument("id"){
type = NavType.LongType
defaultValue = -1
}
)
){
val id = it.arguments?.getInt("id") ?: -1
val actionText = if(id != -1) "Save" else "Add"
val title = if(id != -1) "Edit Book" else "Add New Book"
BookScreen(navHostController, title=title, actionText=actionText)
}
Run Code Online (Sandbox Code Playgroud)
从另一个屏幕内:
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = {
rootNavHostController.navigate(Graph.BOOK)
}) {
Icon(Icons.Filled.Add,null)
}
}
Run Code Online (Sandbox Code Playgroud)
我认为,您可以将{id}可选参数作为参数。但是,不确定为什么现在不起作用。
我想显示\xe2\x88\x9e具有 Unicode 的无穷大符号U+221E。我目前正在使用fmt库,它应该有很多支持并且是跨平台的。
fmt::print("", fmt::styled("\xe2\x88\x9e >", fmt::emphasis::bold | fg(fmt::color::aquamarine)));\nRun Code Online (Sandbox Code Playgroud)\n我得到以下输出:
\n? >\nRun Code Online (Sandbox Code Playgroud)\n我也尝试过设置:setlocale(LC_ALL, "en_US.UTF-8");没有帮助。我使用的是 Windows 11 x64。
警告:
\nwarning C4566: character represented by universal-character-name \'\\u221E\' cannot be represented in the current code page (1252)\nRun Code Online (Sandbox Code Playgroud)\nMS Visual Studio 2022 IDE。
\n我应该在项目属性中更改字符集吗?当前设置为:使用 Unicode 字符集,第二个选项是:使用多字节字符集。
\ninter :: [Integer] -> [Integer] -> [Integer]\ninter s1 s2 = [s | s <- s2, s `elem` s1]\n\ninter [5, 6, 3, 1], [5, 2, 1, 3]\n\nmain = return()\nRun Code Online (Sandbox Code Playgroud)\n我不确定如何测试上述实现,我试图在这里传递两个不同的列表。
\n我不断得到:
\nGHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help\nLoaded GHCi configuration from /home/runner/University-Labs/.ghci\n[1 of 1] Compiling Main ( Main.hs, interpreted )\n\nMain.hs:4:19: error: parse error on input \xe2\x80\x98,\xe2\x80\x99\n |\n4 | inter [5, 6, 3, 1], [5, 2, 1, 3]\n | ^\nFailed, no modules loaded.\n\xee\xba\xa7 \n<interactive>:1:1: error:\n \xe2\x80\xa2 Variable not in …Run Code Online (Sandbox Code Playgroud) 代码:
\nproduct :: (Eq p, Num p) => p -> p\nproduct 1 = 1\nproduct n = n * product (n-1)\nRun Code Online (Sandbox Code Playgroud)\n用法:
\nmain = print (product(8))\nRun Code Online (Sandbox Code Playgroud)\n错误:
\nGHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help\nLoaded GHCi configuration from /home/runner/University-Labs/.ghci\n[1 of 1] Compiling Main ( Main.hs, interpreted )\n\nMain.hs:3:17: error:\n Ambiguous occurrence \xe2\x80\x98product\xe2\x80\x99\n It could refer to\n either \xe2\x80\x98Prelude.product\xe2\x80\x99,\n imported from \xe2\x80\x98Prelude\xe2\x80\x99 at Main.hs:1:1\n (and originally defined in \xe2\x80\x98Data.Foldable\xe2\x80\x99)\n or \xe2\x80\x98Main.product\xe2\x80\x99, defined at Main.hs:2:1\n |\n3 | product n = …Run Code Online (Sandbox Code Playgroud) Before, I posted here, I Googled a lot. I found the following: MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))){} from the following SO post: Jetpack compose DropdownMenu With rounded Corners
EDIT: I am using Material Design v3.
MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))) {
IconButton(
onClick = { showMenu = !showMenu }) {
Icon(imageVector = Icons.Outlined.MoreVert, contentDescription = "")
DropdownMenu(
expanded = showMenu,
onDismissRequest = { showMenu = false },
modifier = Modifier.background(MaterialTheme.colorScheme.background).padding(4.dp)
) {
DropdownMenuItem(text = { Text("Refresh", fontSize = 16.sp) }, …Run Code Online (Sandbox Code Playgroud) android android-jetpack-compose android-jetpack-compose-material3 android-compose-dropdownmenu
我试图锁定应用程序入口屏幕的屏幕方向,然后将实际应用程序及其功能反转回正常状态。
val systemUiController = rememberSystemUiController()
val context = LocalContext.current
Run Code Online (Sandbox Code Playgroud)
我观看了本教程,https://www.youtube.com/watch?v =U5G25kcaNu0,它使用了这一行:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTAIT)
Run Code Online (Sandbox Code Playgroud)
但是,这是由活动控制的。我想知道是否可以按屏幕视图执行此操作。
我刚刚安装:npm i node-id3,来自:https ://www.npmjs.com/package/node-id3 。讽刺的是,我无法使用这个包。我正在Node.js v18.14.0上运行。
根据链接:
const NodeID3 = require('node-id3')
NodeID3.read(file, function(err, tags) {})
Run Code Online (Sandbox Code Playgroud)
这导致了这样的情况:
const NodeID3 = require('node-id3')
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'C:\Users\root\Documents\GitHub\Database\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
Run Code Online (Sandbox Code Playgroud) android ×4
c++ ×2
haskell ×2
android-compose-dropdownmenu ×1
android-jetpack-compose-material3 ×1
c++20 ×1
fmt ×1
javascript ×1
node.js ×1
unicode ×1