0% found this document useful (0 votes)
22 views6 pages

Financial Management

The document discusses Android operating system and provides details about its features, languages used to build Android projects like Kotlin and Java, and provides a sample code for a basic login page Android project with XML and Java files to get started with building Android apps.

Uploaded by

nathan njehia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

Financial Management

The document discusses Android operating system and provides details about its features, languages used to build Android projects like Kotlin and Java, and provides a sample code for a basic login page Android project with XML and Java files to get started with building Android apps.

Uploaded by

nathan njehia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

What is Android?

Android is the Linux-based open-source operating system for mobile devices like smartphones
and tablets. However, nowadays, many other devices are incorporating android in them to turn
them into smart devices such as Smart TVs, Smart car interface for GPS, electrical appliances,
etc. This software was unveiled in 2007 and the first Android Device was launched in September
2008. Since then Google, the sponsor of Android has been releasing its software updates,
versions almost every year.
Android also offers several features:

1. NFC (Near Field Communications): NFC Allows electric devices to easily interact across
short distances.
2. Alternate keywords: It supports multiple keyboards & makes them easy to install.
3. Beautiful and Interactive UI
4. Storage: SQLite a lightweight relational DB is used for data storage.
5. Multi lang: Supports single direction & Bi-Directional.

Roadmap to Building Android Projects


The first and foremost step would be to learn Android tools, but before that, I would recommend
you to learn Android compatible languages like Kotlin or Java, XML at the basic level. The
Android Studio Tool makes use of these languages to build its applications.
Lastly, stay motivated and do not give up practicing to make your projects work. Build as many
as you can.

Kotlin vs Java: Which Language to Choose?


Kotlin has been announced as the official language for Android, it is robust, statically and much
more verbose than Java. But it is hard to deny the fact that Java has been around for 20 years
now and Android has been built on Java since its initial days. So which one to use from Java and
Kotlin, for your project development?

1. Kotlin offers many pros like faster to write, unlike Java which is a type of heavy
language and therefore more code and increased chances for errors and bugs.
2. As Android is built on Java, there are plenty of Java Libraries. Kotlin uses these Java
Libraries and Java frameworks, thanks to Java Bytecode.
3. Java apps are lighter and compact resulting in a faster app experience.

There are many other pros and cons for both the languages. But if you are a beginner or new to
programming, learning and building Java is recommended. The choice you make entirely
depends on the need and requirements of your projects and also what interests you the most.
ASSIGNMENT
Let us look at an easy Android project Idea with source code to start with.
Use the example to create a login page for a KCA University login page

Login Page
Almost every Android application requires a user to make its signup page by providing its
credentials like name, email address, phone number, and then generating a user password to
login later. This is the most basic project to start with as whatever application you make a login
screen is a must whether the domain is health, food, pharmacy, shopping, social media, games
every app requires you to create an account so that the user can save its details and start from
their last session.

XML File:
The Login page XML file contains a user-friendly activity page that displays edit text fields for
the user to enter the required information. It also contains a button and two clickable text fields
to login, create accounts, and change passwords respectively. In the end it contains a clickable
text field for the new users to sign up.
Java File
The Login page Java file takes the inputs from the user and verifies and validates the data and
then stores the information into the local database.
Sample Code

XML File

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout 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"
android:orientation="vertical"
android:id="@+id/content"
tools:context=".MainActivity">
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Login Page"-->
<!--android:textSize="52dp"-->
<!--android:textColor="#FFF"-->
<!--android:textAlignment="center"-->
<!--android:background="#03A9F4"-->
<!--android:layout_marginRight="30dp"-->
<!--android:layout_marginLeft="70dp"-->
<!--android:layout_marginTop="30dp"-->
<!--android:textStyle="bold"/>-->
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/hackr"
android:layout_marginTop="50dp"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="70dp"
app:boxStrokeColor="#223CD6"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Username"
android:inputType="text"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
app:boxStrokeColor="#223CD6"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password"
android:inputType="text"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/login_button"
android:layout_width="189dp"
android:backgroundTintMode="multiply"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:layout_marginRight="120dp"
android:layout_marginTop="30dp"
android:backgroundTint="#03A9F4"
android:text="Login"
android:textColor="#FFFFFF"
android:textSize="28dp" />
<TextView
android:id="@+id/create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:layout_marginRight="120dp"
android:textAlignment="center"
android:layout_marginTop="20dp"
android:textSize="18dp"
android:textStyle="bold"
android:textColor="#03A9F4"
android:text="Create Account"/>
<TextView
android:id="@+id/change_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:layout_marginRight="120dp"
android:textAlignment="center"
android:layout_marginTop="20dp"
android:textSize="18dp"
android:textStyle="bold"
android:textColor="#03A9F4"
android:text="Change Password" />
</LinearLayout>
Java File

package com.skarora.loginpage;
import android.content.Intent;
import android.database.Cursor;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
TextInputLayout username,password;
TextView create,change_pass;
Button login;
LoginData ld;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
username = findViewById(R.id.et_username);
password = findViewById(R.id.et_password);
login = findViewById(R.id.login_button);
create = findViewById(R.id.create);
change_pass = findViewById(R.id.change_password);
ld=new LoginData(this);
createUser();
loginUser();
changePassword();
}
public void loginUser(){
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = username.getEditText().getText().toString();
String pass = password.getEditText().getText().toString();
showMessage("Name",name);
showMessage("Pass", pass);
Cursor loginStatus= ld.validate(name,pass);
if(name.equals("") || pass.equals(""))
{
showMessage(" ERROR!! ", "EMPTY FIELDS");
}
else
if(loginStatus.getCount()==0)
{
Toast.makeText(getApplicationContext(),"hello",Toast.LENGTH_LONG).show();
// showMessage("Login Successful" , "You have successfully logged in :) ");
Intent in = new Intent(getApplicationContext(),Home.class);
startActivity(in);
}
else
{
Toast.makeText(getApplicationContext(),"hiii",Toast.LENGTH_LONG).show();
showMessage("ERRR...", "TRY AGAIN!!!!!");
}
}
});
}
public void createUser()
{
create.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),Create_Acc.class);
startActivity(i);
}
});
}
public void changePassword()
{
change_pass.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),ChangePass.class);
startActivity(i);
}
});
}
public void showMessage(String title, String message)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
}

You might also like