Motivation
Sometimes you want to redirect the user from your app to the website for e.g. imprint and data protection info.
So it can be helpful to open up a website directly from your app.
Implementation
In Switch between activities you learned that the standard way of switching between activities is an intent.
The same goes for open up the browser on your phone. The intent is called the “ACTION_VIEW
”
import android.content.Intent
import android.net.Uri
val browserIntent = Intent(Intent.ACTION_VIEW)
browserIntent.data = Uri.parse("https://prestissimo-guitar.com/")
startActivity(browserIntent)
Further Reading
Passing data between AndroidActivities