What is Android?
Android is the Linux-based open-source operating system for mobile devices like smartphones & 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 & 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:
- NFC (Near Field Communications): NFC Allows electric devices to easily interact across short distances.
- Alternate keywords: It supports multiple keyboards & makes them easy to install.
- Beautiful and Interactive UI
- Storage: SQLite a lightweight relational DB is used for data storage.
- 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. These are various recommended android courses and tutorials at Hackr and various other platforms. 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 & 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.
- Kotlin offers many pros like faster to write, unlike Java which is a type of heavy language and therefore more code & increased chances for errors and bugs.
- As Android is built on Java, there are plenty of Java Libraries. Kotlin uses these Java Libraries and Java frameworks, thanks to Java Bytecode.
- Java apps are lighter & compact resulting in a faster app experience.
There are many other pros and cons for both the languages to know more read Kotlin vs Java here. But if you are a beginner or new to programming learning & building Java is recommended. The choice you make entirely depends on the need and requirements of your projects & also what interests you the most.
Related Course
The Complete Android 12 & Kotlin Development Masterclass
Android Projects for Beginners
Let us look at some of the easy Android project Ideas with source code to start with.
1. 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();
}
}
2. Basic Calculator Application
Calculator application is also a good decision to begin building Android projects as it is present in every phone and tablet. The application helps you learn different layouts required designing the application on the front end i.e. through the XML file and thus defining the button applications i.e. taking numbers and operations as the input and displaying the result as output in the Java file.
The sample below builds a very basic app where the user inputs two numbers in two different text fields and then selects the operation by clicking the button and the result is displayed. On clicking the reset button the calculator resets and the user can enter the values again.
XML File:
The XML file uses Linear Layouts to present the text fields and operations button.
Java File:
The Java files describe the functionality of each button, do the math, and display the result.
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"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#FFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#FFF">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Basic Calculator"
android:textAlignment="center"
android:textColor="#000"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#FFF"
android:layout_gravity="center">
<EditText
android:id="@+id/firstVal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Enter First Number"
android:textColorHint="#03A9F4"
android:textAlignment="center"
android:textSize="20dp"
android:textColor="#000"
android:inputType="numberDecimal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#FFF"
android:layout_gravity="center">
<EditText
android:id="@+id/secondVal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Enter Second Number"
android:textColorHint="#03A9F4"
android:textAlignment="center"
android:textSize="20dp"
android:textColor="#000"
android:inputType="numberDecimal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="20dp"
android:layout_marginRight="0dp"
android:background="#FFF"
android:layout_gravity="center"
>
<Button
android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#03A9F4"
android:onClick="add"
android:text="+"
android:textSize="15dp" />
<Button
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#03A9F4"
android:onClick="add"
android:text="-"
android:textSize="15dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#03A9F4"
android:onClick="add"
android:text="/"
android:textSize="15dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#03A9F4"
android:onClick="add"
android:text="*"
android:textSize="15dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#FFF"
android:layout_gravity="center">
<Button
android:id="@+id/reset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:textAlignment="center"
android:layout_marginTop="30dp"
android:background="#03A9F4"
android:onClick="reset"
android:text="Reset"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="10dp"
android:background="#FFF"
android:layout_gravity="center">
<TextView
android:id="@+id/result"
android:background="#03A9F4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Result"
android:textSize="30dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:textColor="#FFF"
android:textColorHint="#FFF"
android:textAlignment="center"
android:layout_marginTop="50dp"/>
</LinearLayout>
</LinearLayout>
Java File
package com.skarora.basiccalculator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText et1,et2;
TextView t1,result;
Button b1,b2,b3,b4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1 = findViewById(R.id.firstVal);
et2 = findViewById(R.id.secondVal);
b1 = findViewById(R.id.add);
b2 = findViewById(R.id.sub);
b3 = findViewById(R.id.div);
b4 = findViewById(R.id.times);
result = findViewById(R.id.result);
}
public void add(View view) {
String firstVal = et1.getText().toString();
String secondVal = et2.getText().toString();
double x = Double.parseDouble(firstVal);
double y = Double.parseDouble(secondVal);
result.setText(""+(x+y));
}
public void sub(View view) {
String firstVal = et1.getText().toString();
String secondVal = et2.getText().toString();
double x = Double.parseDouble(firstVal);
double y = Double.parseDouble(secondVal);
result.setText(""+(x-y));
}
public void div(View view) {
String firstVal = et1.getText().toString();
String secondVal = et2.getText().toString();
double x = Double.parseDouble(firstVal);
double y = Double.parseDouble(secondVal);
result.setText(""+(x/y));
}
public void times(View view) {
String firstVal = et1.getText().toString();
String secondVal = et2.getText().toString();
double x = Double.parseDouble(firstVal);
double y = Double.parseDouble(secondVal);
result.setText(""+(x*y));
}
public void reset(View view) {
String firstVal = et1.getText().toString();
String secondVal = et2.getText().toString();
et1.setText(null);
et2.setText(null);
}
}
Intermediate Level Android Project Ideas
Here we have listed the best android project ideas for intermediate level developers:
3. Tic-Tac-Toe
Developing games in Android is a good step to get a hold of this tool and adding an Android game project also opens good opportunities for those seeking a career in Android Development.
Tic-tac-toe is the easiest & popular game to start with. It is a two player game with each player represented by a ”X” & “O”. Each player is required to arrange its “X” or “O” in a straight(horizontal or vertical) or diagonal line & other players must make their own attempts as well as try to block other player’s attempts.
XML File:
The layout contains 9 buttons within nested linear layouts and player points & reset buttons are displayed in the relative layout.
Java File:
The file contains a 2D array of buttons and an assigned on check listener on them that handle the clicks of the player. The file further implements the method checking for the winner. The winner at the end of each turn if any 3 buttons have 3 matching fields.
An integer variable counts & keeps track of the scope & declares a winner after 9 rounds or if they have a draw. The reset buttons reset the board & clear all the points of the player.
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:background="#03A9F4"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_view_p1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Player 1: 0 "
android:textSize="30sp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"/>
<TextView
android:id="@+id/text_view_p2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_p1"
android:text="Player 2: 0"
android:textSize="30sp"
android:layout_marginLeft="10dp" />
<Button
android:id="@+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="33dp"
android:text="reset"
android:background="#FFF"
android:layout_marginRight="33dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/button_00"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_01"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_02"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/button_10"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_11"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/button_20"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_21"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/button_22"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="60sp"
android:background="#B2EBF2"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
Java File
package com.skarora.tictactoe;
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 implements View.OnClickListener {
private Button[][] buttons = new Button[3][3];
private boolean player1Turn = true;
private int roundCount;
private int player1Points;
private int player2Points;
private TextView textViewPlayer1;
private TextView textViewPlayer2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewPlayer1 = findViewById(R.id.text_view_p1);
textViewPlayer2 = findViewById(R.id.text_view_p2);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
String buttonID = "button_" + i + j;
int resID = getResources().getIdentifier(buttonID, "id", getPackageName());
buttons[i][j] = findViewById(resID);
buttons[i][j].setOnClickListener(this);
}
}
Button buttonReset = findViewById(R.id.button_reset);
buttonReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetGame();
}
});
}
@Override
public void onClick(View v) {
if (!((Button) v).getText().toString().equals("")) {
return;
}
if (player1Turn) {
((Button) v).setText("X");
} else {
((Button) v).setText("O");
}
roundCount++;
if (checkForWin()) {
if (player1Turn) {
player1Wins();
} else {
player2Wins();
}
} else if (roundCount == 9) {
draw();
} else {
player1Turn = !player1Turn;
}
}
private boolean checkForWin() {
String[][] field = new String[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
field[i][j] = buttons[i][j].getText().toString();
}
}
for (int i = 0; i < 3; i++) {
if (field[i][0].equals(field[i][1])
&& field[i][0].equals(field[i][2])
&& !field[i][0].equals("")) {
return true;
}
}
for (int i = 0; i < 3; i++) {
if (field[0][i].equals(field[1][i])
&& field[0][i].equals(field[2][i])
&& !field[0][i].equals("")) {
return true;
}
}
if (field[0][0].equals(field[1][1])
&& field[0][0].equals(field[2][2])
&& !field[0][0].equals("")) {
return true;
}
if (field[0][2].equals(field[1][1])
&& field[0][2].equals(field[2][0])
&& !field[0][2].equals("")) {
return true;
}
return false;
}
private void player1Wins() {
player1Points++;
Toast.makeText(this, "Player 1 wins!", Toast.LENGTH_SHORT).show();
updatePointsText();
resetBoard();
}
private void player2Wins() {
player2Points++;
Toast.makeText(this, "Player 2 wins!", Toast.LENGTH_SHORT).show();
updatePointsText();
resetBoard();
}
private void draw() {
Toast.makeText(this, "Draw!", Toast.LENGTH_SHORT).show();
resetBoard();
}
private void updatePointsText() {
textViewPlayer1.setText("Player 1: " + player1Points);
textViewPlayer2.setText("Player 2: " + player2Points);
}
private void resetBoard() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
buttons[i][j].setText("");
}
}
roundCount = 0;
player1Turn = true;
}
private void resetGame() {
player1Points = 0;
player2Points = 0;
updatePointsText();
resetBoard();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("roundCount", roundCount);
outState.putInt("player1Points", player1Points);
outState.putInt("player2Points", player2Points);
outState.putBoolean("player1Turn", player1Turn);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
roundCount = savedInstanceState.getInt("roundCount");
player1Points = savedInstanceState.getInt("player1Points");
player2Points = savedInstanceState.getInt("player2Points");
player1Turn = savedInstanceState.getBoolean("player1Turn");
}
}
Advance Level Android Projects
4. Smart Alarm System
This application is designed to alert you by waking you if you are sleeping or simply alert you if you are listening to music etc & inform you about your stop while commuting so that you don’t miss a stop. On opening the application, you are required to enter or set the destination on which you need to alert upon reaching.
Location can be set by the pin-pointing on the map, where the blue marker points to the current location. The two-button save & discard allows the user the save or discard the changes. The toggle button on the top turns on the tracker, the algorithm calculates the remaining distance to the destination & updates device network connection status thus the application keeps track of the current location & notifies you once you are close enough to your destination.
You may want to check the source code at GitHub.
Conclusion
That brings us to the end of the Android Projects that you could try to begin learning at different levels. I would also recommend that once you build your project try publishing it at the Google Play Store as it would be a good exercise to learn how to publish an app. Although there are millions of Android project ideas on the internet but building something out of the box through your imagination would be worthy enough to give it a try, you never know you could end up making a popular user-friendly app that would open a door of opportunities for you. If you need any help with Android you might want to go through these best Android courses and if you are preparing for an interview we recommend these Android Interview Questions for you. So stay motivated and start building your app.
Happy Developing!
People are also reading: