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.


Prerequisites

Before getting started with Android, you need to be well-versed with a few important concepts in Android Studio:

  1. You must have a clear understanding of Object-Oriented Programming.
  2. You must know the basics of Java.
  3. 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

  1. First of all, make sure you have Android Studio installed and ready in your Computer. 
  2. If you do not have Android Studio, you can follow these Steps to Install Android Studio.
  3. Once you are ready with Android Studio, you can proceed with the steps.

Step 2: Create a New Project

  1. Go to File > New > New Project. After this, the following should be open on your desktop:

Creating a new Android project

Creating a new Android project

   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.

Configuring Android project

Configuring Android project

Step 3

At this point, we should have a screen in front of us that looks something like this: 

Landing screen

Landing screen

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:

Initial layout of activity_main.xml

Initial layout of activity_main.xml

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:

Step 5

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.

Step 6

After writing the code in both XML and Java files, we will now run the application.

The following should be generated:

Final output

Final output

Now, we’ll enter a URL in the EditText, say, https://www.google.com, as shown in the following:

Creating a new Android project

As soon as you click on Take Me There, Google should be opened in your browser, as show below:

URL application success

URL application success

Conclusion

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.

Further Reading



Source link

Write A Comment