How to?Smartphones

Introduction to android App development!

The “Hello world” App

Hello readers,

Today this is going to be a different topic, today we are going to teach you the basics of android app development.

app

WHY ANDROID?

Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It’s the largest installed base of any mobile platform and growing fast. Every day more than 1 million new Android devices are activated worldwide.

This tutorial has been written with an aim to teach you how to develop and package Android application. We will start from environment setup for Android application programming and then drill down to look into various aspects of Android applications.

Pre Requisites: The Latest Version of android studio. The Download and installation instructions can be found in the following link – httpss://developer.android.com/studio/install.

Recommendation – For 8GB Ram and above you may use Windows but below 8GB Ram It is recommended to switch to a lightweight Linux Distro.

The basics of android app development

The bare minimum visible thing in an android app is called an activity, E.g.: in website you call a single page a webpage here in android a single page is called an activity.

A basic android app consists of a main activity which is a java class file which extends the AppCompatActivity (you need not know this now) just think of it as importing all the necessary files for android development.

Now to show the layout of a layout file is created which is an XML file is shown in the activity.

Let’s Make our first App

On opening android studio for the first time this will be the home page.

httpss://developer.android.com/training/basics/firstapp/images/studio-welcome_2x.png
  • Click on start a new project
  • In the Create New Project window, enter the following values:
  • Application Name: “My First App”
  • Company Domain: “example.com”
  • Leave the other options as they are.
  • Click Next.
  • In the Target Android Devices screen, keep the default values and click Next.
  • In the Add an Activity to Mobile screen, select Empty Activity and click Next.
  • In the Configure Activity screen, keep the default values and click Finish.
httpss://developer.android.com/training/basics/firstapp/images/studio-editor_2x.png

This page will open up after you have done all the above steps

Now as you can see there is an xml file which is the layout file and there is a java file which is the main activity file

Now on the java file you can see a function called onCreate(….){….}. this is the main function where all the app related function will be done.

On the onCreate function you can see a function called setContentView(…). This is the function which is used to import the layout and set it to this activity, on this function you can see that the xml file is imported by R.layout.activity_main.

Here R -> Resources folder, Layout -> The layout folder inside the resources folder and activity_main is the name of the xml file.

httpss://developer.android.com/training/basics/firstapp/images/layout-editor_2x.png

Now click on the layout file and the following view will come up as you can already see there is a textbox already present in the layout file where its written hello world.

Now double click on the hello world and it will give you an option to change the hello world text, change it to your name.

And voila your first app is created.

Now to install this app to your device

  • First enable usb debugging on your android
    • Go to about phone
    • Tap multiple times on build number until and unless developer options is enable
    • Go to developer options in the main screen
    • Then enable USB debugging
  • Then connect your mobile to pc via an USB cable and press allow on the phone if asked for
  • Then click on the run button i.e. the green play button as shown below
dev
  • Then it will ask you for which device to install in a deployment target window
httpss://developer.android.com/training/basics/firstapp/images/run-device_2x.png
  • Now double click on your device and it will install and run the app on your phone.

Congrats now you have created your first android app.

Related Articles

Leave a Reply

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

fourteen − 7 =

Back to top button
The Tech Infinite