Introductory Guide to Create Your First Android App With Android Studio
Join the DZone community and get the full member experience.Join For Free
In this article, we’ll learn how we can begin creating our first Android Application. Without any delay, let us begin with the creation of our first application.
Before getting started with Android, you need to be well-versed with a few important concepts in Android Studio:
- You must have a clear understanding of Object-Oriented Programming.
- You must know the basics of Java.
- You should know the basics of XML.
You may also like: Introduction to Android Programming in Android Studio 3.0.
Getting Started - Your First Android App
Now, we’ll begin with our first application.
Step 1: Download and Install Android Studio
- First of all, make sure you have Android Studio installed and ready in your Computer.
- If you do not have Android Studio, you can follow these Steps to Install Android Studio.
- Once you are ready with Android Studio, you can proceed with the steps.
Step 2: Create a New Project
- Go to File > New > New Project. After this, the following should be open on your desktop:
Here, we’ll select Empty Activity and proceed further by clicking on Next.
2. Now, we’ll name our application and choose the language we prefer. Then, press Finish.
At this point, we should have a screen in front of us that looks something like this:
There two areas where we’re going to write the code for our application. The two sections are MainActivity.java and activity_main.xml. Both files come together to make our application function.
Step 4: Configuring activity_main.xm
Initially, we’ll have the following code in the layout file:
We can change the message that is written in the line:
android:text= “Hello World”. We’ll change it to
“Hello World, I’m here to take you to the URL to enter”.
We’ll also add a
Button and an
EditText component where users can enter a URL. To add this, we’ll add the following code in the activity_main.xml file:
Now, we’ll write the following code to implement the
onClick() action of the button in the MainActivity.java file. The application that we are developing will take us to the respective URL. To implement this we will use Intents - Android Intent and Intent Filters.
After writing the code in both XML and Java files, we will now run the application.
The following should be generated:
Now, we’ll enter a URL in the EditText, say, https://www.google.com, as shown in the following:
As soon as you click on Take Me There, Google should be opened in your browser, as show below:
Yes, making an Android application in Android Studio is this easy! You just need to have Android Studio installed. The next step would be to create a new project and name it. The rest of the steps are explained in the article. Now, it’s your turn to implement it and learn how interesting it is to create an application.
- Top Must-Have Android Developer Tools.
- Fuchsia OS: Google’s New Android?
- Android App Architecture [Part 4] Presentation Layer.
Opinions expressed by DZone contributors are their own.