Everything you need to know about Android applications

Applications are essential part of Android and do most of the things you don’t know about. If you ever went to Apps section in settings you have probably seen dozens of applications that you are unfamiliar with and that is good thing.

These apps are meant to be silent and control things like locations service( which makes GPS usable ) and then there are apps which make interaction with user and OS like application launcher, status bar, settings, phone etc. for the most part everything you see on screen apps. Android has more than 2.2 million apps available which are located on Google Play Store. With so many apps what makes them unique or better then other apps.

Every applications is made from Activities, Views, Fragments etc. and Manifest file which defines every application( applications  identity card ).

android-studio-lubuntu-project-workspace-300x163

Activities

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows. Activities are usually located in java/packagename folder. Every activity is defined in Manifest where every Activity has its name and category and other attributes like label and icon.

<activity android:name=”.ExampleActivity” android:icon=”@drawable/app_icon”>
       <intent-filter>
                <action android:name=”android.intent.action.MAIN” />
                <category android:name=”android.intent.category.LAUNCHER” />
       </intent-filter>
</activity>

Activity life cycle

Layouts

A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. You can declare a layout in two ways:

  • Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.
  • Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

XML files are always located in res/layouts folder and are usually name by activity they belong to. Example of XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello, I am a TextView" />
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello, I am a Button" />
</LinearLayout>

Leave a comment

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