Beginners Guide: How to Build an Android App With Android Studio

Build an Android App With Android Studio

This article will teach you the basics of building an Android application under the Android Studio development environment. As we can see that Android devices are becoming more common, we can also conclude that this will also result in a rapid speed in the demand of the new applications.

Android studio is a free and easy to use the platform to work on, as it provides a splendid development environment. It is the best platform for the users having working experience over Java programming language because it is the only language used by Android. We are not using many codes in this article, which will let you understand it more easily.

The complete process will take approximately 30-60 minutes, depending upon the time you take to download and install Android studio. After using this article for developing your first Android application, you will surely head on your way to a fun new hobby or possibly even a promising career in mobile development.

Step by Step Guide to Create an Android App With Android Studio

Let us have a look at the steps for developing an Android application using Android studio:

Step 1: Install Android Studio

To install Android Studio, you must follow the following steps:

Step 2: Open a New Project

To start a new project you must follow the following points:

  • Open Android Studio
  • Select “Start a new Android Studio project”, under the “Quick Start” menu.New Android Studio Project
  • Name your project, for example, “Let’s Move”, on the “Create new project” window that opens.
  • Set the company name if you want.
  • Note the location of the project file and change it if you want.
    Click “Next”.New Android Studio Project
  • Ensure that “Phone and Tablet” are the only box that is checked.New Android Studio Project
  • Before testing the application on your device, you have to make sure that the minimum SDK is below your phone’s operating system level.
  • Click “Next”.
  • Select “Blank Activity”.
  • Click “Next”.New Android Studio Project
  • Leave rest of the Activity name fields as they are.
  • Click “Finish”.New Android Studio Project

Step 3: Edit the Welcome Message in the Main Activity

  • Open the activity_main.XML tab if it is not already opened.
  • Ensure that the design tab is opened on the activity_main.XML display.
    Welcome Message in the Main Activity
  • Drag the “Let’s Move!” from the upper left corner of the phone display to the center screen.
  • Open the values folder, located in the project file system on the left side of the window.
  • Double-click on the strings.XML file, present in the values folder.
  • Find the “Let’s Move!” in this file.
  • Add “Welcome to my application!”, after the “Let’s Move!” message.
  • Go back to the activity_main.XML tab.
  • Ensure that your center text now reads “Let’s Move! Welcome to my application!”.Welcome Message in the Main Activity

Step 4: Add a Button to the Main Activity

  • Go to the Design tab of the activity_main.XML display.
  • Find “Button”, under the heading Widgets in the palette menu to the left of the phone display.
  • Click and drag the button under your welcome message.
  • Ensure that your button is still selected.
    Add a Button to the Main Activity
  • Scroll down to find the field for “text”, in the properties menu on the right side of the window.
  • Change the text from “New Button” to “Next Page”

Step 5: Create a Second Activity

  • Right click on the “app” present at the top of the project’s file system tree.
  • Then go through New > Activity > Blank Activity.
  • Change the name of Activity to “SecondActivity”.
    Android Studio Second Activity
  • Click “Finish”.
  • Ensure that you are in the Design view of activity_second.xml.
  • Just like you did on the Main Activity, you now have to drag the text box in the upper left corner of the phone display down to the center screen.
  • Select the text box, find the “id” field in the Properties menu on the right and set it to “text2”.
  • Open strings.xml.
  • Add a new line under the “Hello world! Welcome to my application”, which reads “Welcome to the second page!”.
  • Go back to activity_second.xml.
  • Select the text box once again.
  • Set the “text” field to “@string/second_page”, in the Properties pane.
  • Ensure that the text box now reads “Welcome to the second page!” and is located in the center of the screen on the phone display.

Step 6: Write the Button’s “onClick” Method
Button’s “onClick” Method

  • Select the MainActivity.java tab along with the top of the work environment.
  • Add the following coding lines at the end of the onCreate method:
    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.onClickListener() {
    @Override
    public void onClick(View v) {
    goToSecondActivity();
    }
    });
  • Add the following method to the bottom of the MainActivity class:
    private void goToSecondActivity() {
    Intent intent = new Intent(this, SecondActivity.class);
    startActivity(intent);
    }
    Click on “+ next” to import at the third line of MainActivity.java to expand the import statements.
  • Add the following to the end of the import statements if they are not already there:
    import android.content.Intent;
    import android.view.View;
    import android.widget.TextView;the end of the import statements

Step 7: Test the Application

  • Click on the green play button located on the toolbar at the top of the Android Studio window.
  • After a few moments, when the “Choose Device” dialog box appears, select the “Launch emulator” option.
  • Click OK.
    Test the Application
  • After a few more moments, as the emulator opens, the application will automatically launch the app upon the virtual phone being unlocked.
  • Now, make sure that all of your message texts display correctly, and the button takes you to the next page.

Step 8: Up, Up, and Away

Lets move Android app
Bravo!, you have developed your first Android application with ground level functionality. You have now created an application having a page greeting the user and a button, which takes you to the next page.

Written by SAG_IPL

SAG IPL, a Jaipur based top mobile app development company with CMMI Level 3 accreditation, is a renowned name in this field since 2010. The company is focussed on delivering top websites, mobile applications and other IT solutions, as per the requirement and demand of the clients.

Leave a Reply

Your email address will not be published. Required fields are marked *