Hello Android Example || Hello World Example In Android - Android Tutorial World

Latest

Welcome to Android Tutorial World Blog, Here you can find all type of post or tutorial related to andorid app development in details.

Tuesday, September 10, 2019

Hello Android Example || Hello World Example In Android


 
Step 1.
Run Android Studio and create a new Android Studio project

Step 2.
Now Select Any Activity (For new fresh project use Empty Activity)

Step 3.
Now Enter Your Application Name, Package name of application / Your Company Domain ( Like:- com.your website name.your application name ), Project Location, Language ( In This Tutorial we use Java Language ) and Minimum API level ( The min API level is the minimum version of the Android operating system required to run your application ) ( In this tutorial we use API 22. This is Android 5.1( Lollipop ) )


Now an android project has been created. You can explore the android project and see the simple program, it looks like this:


Now you see 2 files in the project
1. activity_main.xml
2. MainActivity.java


Android studio auto generates code for activity_main.xml file. You may edit this file according to your requirement.

XML file looking like this

   <?xml version="1.0" encoding="utf-8"?
    androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


   <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

  </androidx.constraintlayout.widget.ConstraintLayout> 


Java file looking like this

 package com.akshayarora.myapplication;

 import androidx.appcompat.app.AppCompatActivity;
 import android.os.Bundle;

 public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
 }

Now Connect Your Device to your PC / laptop
Before connecting your device to your PC / laptop Enable Developer Option


Now run the Android Application
Click the run icon on the toolbar or simply press Shift + F10.
Now Select Your Device then click on OK Button
This process takes 2 to 3 minutes
While Installing time click on the Install option on your device
After Install Application Automatically Launch
The application Looks like this




Thank you!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.