A.E*_*sam 6 android uri android-intent kotlin
我想将我的应用程序中的按钮与网站链接,因为当用户单击此按钮时,网站会在浏览器或应用程序中打开,我使用的是 kotlin 而不是 java,我该怎么做?:) 我尝试使用此代码:
bu1.setOnClickListener({
var gourl= Intent(this,Uri.parse("https://www.facebook.com/"))
startActivity(gourl)
})
bu1.setOnClickListener({
var gourl= Intent(this,Uri.parse("https://www.facebook.com/"))
startActivity(gourl)
})
bu1.setOnClickListener({
var gourl= Intent(this,Uri.parse("https://www.facebook.com/"))
startActivity(gourl)
})
Run Code Online (Sandbox Code Playgroud)
这样做:
val url = "http://www.example.com"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
Run Code Online (Sandbox Code Playgroud)
或者像这样:
val i = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"))
startActivity(i)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8316 次 |
| 最近记录: |