
This code first checks whether there is a network connection. setIcon(android.R.drawable.ic_dialog_alert).show() Add the following code below url and inside onCreate(): doAsync Start with a narrow search at first so you aren’t overwhelmed with too much data. It queries the GitHub API for repositories written in Kotlin that contain the phrase “super mario”. MainActivity.kt defines a value url that contains the first network request. Now that you have your permissions set up, you can move on to making your first network request! Initiating a Request on a Background Thread Open manifests/AndroidManifest.xml and add the following permissions above the application tag: ĪCCESS_NETWORK_STATE checks the network state of the device. Your app must include certain permissions to perform network operations in Android. Check the Optimize imports on the fly (for current project) checkbox, too. Then go to Editor ▸ General ▸ Auto Import and check the Add unambiguous imports on the fly checkbox. Go to either Android Studio ▸ Preferences on macOS or File ▸ Settings on PC. This step saves you from having to add individual import statements. RecyclerView contains a hard-coded list of repository names.īuild and run to preview what you have to work with:īefore adding any Kotlin code, configure Android Studio to insert import statements automatically. It uses a simple RecyclerView named repoList. Open MainActivity.kt from the ui.activities package and explore the code. Then browse to the starter directory in the downloaded materials and click Open.

You can also use File ▸ Open in Android Studio.

Open the starter project in Android Studio 3.1.2 or greater by selecting Open an existing Android Studio project from the Welcome to Android Studio window: Once your download completes, unzip the file. Getting Startedĭownload the starter project by clicking the Download Materials button at the top or bottom of the tutorial. If you’re new to Android development, read through our Beginning Android Development tutorials to familiarize yourself with the basics. Note: This tutorial assumes you’re familiar with the basics of Android development.
