The Very Basics of Android: Starting Activities
When you click on a link on a webpage to navigate to another webpage, what do you need to tell the backend in order for it to fetch the right page for you? First, you have to tell the backend which page you want to see. Second, you have to tell the backend any extra information it might require. You take these two pieces of information, package them into a nice bundle of data called a URL and send it off to the backend. When we launch an activity, we do a very similar thing. First, we get the name of which activity we want to open. Then we package together any extra information we might need to show this page into a nice bundle. We package these two pieces of information together into an object called an Intent and then we send it off to the Android OS using the very aptly named `startActivity` command. Here's what an Intent looks like in code: Intent(context, SearchActivity::class.java) .apply { putExtra("q", "duolingo") } Ignoring the context for now, t...