Android Blood Bank App Project
Introduction
In a world where every second counts, especially in emergency healthcare situations, the Android Blood Bank app serves as an innovative solution. This application acts as a digital bridge connecting blood donors and recipients, thereby accelerating the process of blood donation and potentially saving lives.
Core Features
- Donor Information: The app hosts a comprehensive database of registered blood donors, detailing their blood group, medical history, and personal information like name and address.
- User Authentication: A robust login system ensures that only registered users have access to the database, preserving the integrity and privacy of the listed donors.
- Swift Decision-making: The application’s intuitive interface allows users to quickly identify and select suitable donors, cutting down the time usually spent in this critical task.
Advantages
- Security: The login feature prevents unauthorized access, ensuring that only registered users can access the crucial donor database.
- Efficiency: Through its quick search algorithm, the blood bank android app dramatically reduces the time needed to find the right blood donor.
- Accessibility: Being a mobile application, it is available at the touch of a button, any time and any place.
Disadvantages
- Server Dependence: One significant drawback is that the system relies on internet connectivity. In the event of server downtime, users will not be able to access the database.
Conclusion
The Android Blood Bank application serves an essential role in modern healthcare, providing a quick and efficient method for blood donor matching. Although it has its limitations, the benefits far outweigh the drawbacks, making it a vital tool in expediting emergency medical care.
Sample Code
create a new Android Activity called ‘LoginActivity.java
‘:
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class LoginActivity extends AppCompatActivity {
private EditText emailEditText, passwordEditText;
private Button loginButton, registerButton;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mAuth = FirebaseAuth.getInstance();
emailEditText = findViewById(R.id.emailEditText);
passwordEditText = findViewById(R.id.passwordEditText);
loginButton = findViewById(R.id.loginButton);
registerButton = findViewById(R.id.registerButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loginUser();
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser();
}
});
}
private void loginUser() {
String email = emailEditText.getText().toString();
String password = passwordEditText.getText().toString();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(LoginActivity.this, "Login successful", Toast.LENGTH_SHORT).show();
// Navigate to next activity
} else {
Toast.makeText(LoginActivity.this, "Login failed", Toast.LENGTH_SHORT).show();
}
}
});
}
private void registerUser() {
String email = emailEditText.getText().toString();
String password = passwordEditText.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(LoginActivity.this, "Registration successful", Toast.LENGTH_SHORT).show();
// Navigate to next activity
} else {
Toast.makeText(LoginActivity.this, "Registration failed", Toast.LENGTH_SHORT).show();
}
}
});
}
}
XML layout file, ‘activity_login.xml
‘:
<?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"
android:padding="16dp">
<EditText
android:id="@+id/emailEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email" />
<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login" />
<Button
android:id="@+id/registerButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Register" />
</LinearLayout>
In order to download the PDF, You must follow on Youtube. Once done, Click on Submit
Follow On YoutubeSubscribed? Click on Confirm