英文:
How to redirect to application, When CardView was Clicked using kotlin in android studio?
问题
@Composable
fun mycard(
data: MyModel,
) {
var value = Card(
elevation = 14.dp,
shape = RoundedCornerShape(20.dp),
modifier = Modifier
.padding(horizontal = 12.dp)
.width(350.dp)
.height(190.dp)
.background(Color.Transparent)
.clickable {
val launchIntent =
packageManager.getLaunchIntentForPackage("com.google.android.youtube.tv")
launchIntent?.let { startActivity(it) }
}
)
英文:
@Composable
fun mycard(
data: MyModel,
) {
var value = Card(
elevation = 14.dp,
shape = RoundedCornerShape(20.dp),
modifier = Modifier
.padding(horizontal = 12.dp)
.width(350.dp)
.height(190.dp)
.background(Color.Transparent)
.clickable {
val launchIntent =
packageManager.getLaunchIntentForPackage("com.google.android.youtube.tv")
launchIntent?.let { startActivity(it) }
}
I have added the card and the card was clickable but not redirect to specific application please solve my doubt
答案1
得分: 2
使用此脚本:
apps.setOnClickListener {
val packageName = "com.google.android.youtube.tv"
val intent = packageManager.getLaunchIntentForPackage(packageName)
if (intent != null) startActivity(intent)
else
Toast.makeText(this, "该应用未安装!", Toast.LENGTH_SHORT).show()
}
英文:
Use this Script ;
apps.setOnClickListener {
val packageName = "com.google.android.youtube.tv"
val intent = packageManager.getLaunchIntentForPackage(packageName)
if (intent != null) startActivity(intent)
else
Toast.makeText(this, "The Application is not installed!", Toast.LENGTH_SHORT).show()
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论