Android Studio: Basics of Android Studio



-------INTERNAL DETAILS OF ANDROID PROJECTS--------





  • Firstly we are going to learn about the "AndroidManifest.xml" file. Regardless of any project you create it must contain manifest file in it.
Android Manifest is one of the most important file for the working of android project. You should must configure the manifest file correctly to get desired output, otherwise it throws lots of errors. It may leads to fail locating further activity.

In manifest you can also order the activities, and also set the first activity which will launched as app launched.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.jessicathornsby.myapplication">

   <application
       android:allowBackup="true"
       android:icon="@mipmap/ic_launcher"
       android:label="@string/app_name"
       android:roundIcon="@mipmap/ic_launcher_round"
       android:supportsRtl="true"
       android:theme="@style/AppTheme">
       <activity android:name=".MainActivity">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />

               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
   </application>

</manifest>
This is a "AndroidManifest file of new project.


  • Now, lets discuss about the "MainActivity.java" file. This file helps us to perform all the logical and Arithmetic operations at back-end. We can configure this file with all types of validation process or establishing connection with databases and servers.
A newly generated "MainActivity.java" file consists of package name, some basic imports, one public class and "OnCreate method" connecting to its respective front-end.
package com.example.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);
    }
}

This is a "MainActivity.java" file of new project.


  • Now, In this section Lets discuss about "activity_main.xml" file. This file is used to design the front-end of the android project.
<?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>





Comments

Popular posts from this blog

Android Studio: Creating Android Studio Project

LINUX: How to Remove Grub