Make Better Business Decisions with Advanced Android CRM

FREE Online Courses: Transform Your Career – Enroll for Free!

Customer Relationship Management (CRM) is an essential aspect of business management that involves building and maintaining long-term relationships with customers. In this project, we will be creating an Advanced CRM Android app that has two modules, Employer and Employees.

The Employer can create tasks, delete tasks, and register new users to the app. The Employees can view the tasks and update their status, whether they are complete or incomplete.

This app will be designed to streamline communication between employers and employees, thereby enhancing productivity and efficiency.

About Android CRM App

The objective of this project is to guide you through the process of creating an Advanced CRM Android app that enables employers to create tasks, delete tasks, and register new users to the app. Employees can view the tasks assigned to them and update their status, whether they are complete or incomplete.

By the end of this project, you should be able to create a basic Advanced CRM app that can be customized to fit your personal or professional needs.

Prerequisites for CRM App using Android

To follow along with this project, you will need the following:

  • A computer running Android Studio.
  • Basic knowledge of Java and Android app development using Android Studio.
  • An Android device or emulator to test the app

Download Android CRM App Project

Please download the source code of Android CRM App Project from the following link: Android CRM App Project Code

Steps to Create CRM App using Android

Following are the steps for developing the Android CRM App Project:

Step 1: Creating the android project using java as the language and adding the firebase library using the inbuilt firebase library assistant in the Android Studio.

android studio output

Step 2: Creating Login form layout: It will be used to login both the employer and employee.

employee output

Login.java

package com.dataflair.advancedcrm;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

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 Login extends AppCompatActivity {

   EditText mEmail, mPassword;
   Button mLoginBtn;
   ProgressBar progressBar;
   FirebaseAuth fAuth;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_login);

       // if user is already logged in, redirect to main activity
       if(FirebaseAuth.getInstance().getCurrentUser() != null){
           if(FirebaseAuth.getInstance().getCurrentUser().getEmail().equals("[email protected]")) {
               startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
               finish();
           }
           else{
               startActivity(new Intent(getApplicationContext(), LoggedEmployee.class));
               finish();
           }
       }


       mEmail      = findViewById(R.id.logEmail);
       mPassword   = findViewById(R.id.logPassword);
       mLoginBtn   = findViewById(R.id.loginButton);
       progressBar = findViewById(R.id.progressBarLogin);
       fAuth       = FirebaseAuth.getInstance();

       mLoginBtn.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               final String email = mEmail.getText().toString().trim();
               String password = mPassword.getText().toString().trim();

               //email and password validation
               if (TextUtils.isEmpty(email)){
                   mEmail.setError("Email address required!");
                   return;
               }

               if(TextUtils.isEmpty(password)){
                   mPassword.setError("Password required!");
                   return;
               }

               if(password.length()<6){
                   mPassword.setError("Password must be at least 6 characters long!");
                   return;
               }
               //Authenticate user

               fAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                   @Override
                   public void onComplete(@NonNull Task<AuthResult> task) {

                       if(task.isSuccessful()){
                           String email= mEmail.getText().toString();
                           if(email.equals("[email protected]")) {

                               Toast.makeText(Login.this, "Admin Logged in Successfully", Toast.LENGTH_SHORT).show();
                               startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
                           }
                           else{
                               startActivity(new Intent(getApplicationContext(), LoggedEmployee.class));
                           }

                       }
                       else{
                           Toast.makeText(Login.this, "Incorrect email or password!" , Toast.LENGTH_SHORT).show();
                       }
                   }
               });


           }
       });


   }


   @Override
   protected void onStart() {
       super.onStart();

       if(fAuth.getCurrentUser() != null){
           //check if user is admin
           String email= mEmail.getText().toString();
           if(email.equals("[email protected]")) {

               Toast.makeText(Login.this, "Admin Logged in Successfully", Toast.LENGTH_SHORT).show();
               startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
           }
           else{
               Toast.makeText(this, "User Logged in Successfully", Toast.LENGTH_SHORT).show();
               startActivity(new Intent(getApplicationContext(), LoggedEmployee.class));
           }
       }
   }
}

Step 3: Creating Employee Home Page and Employer Home Page : It will allow the employer to Create tasks, check task progress and Add new employees to the app. While Employee can Only view his/her tasks.

Employee Home Page

employee home page output

LoggedEmployee.java

package com.dataflair.advancedcrm;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.google.firebase.auth.FirebaseAuth;

public class LoggedEmployee extends AppCompatActivity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_logged_employee);
   }
   public void logout(View view){
       FirebaseAuth.getInstance().signOut();
       startActivity(new Intent(getApplicationContext(), Login.class));
       finish();

   }
   public void tasks(View view){

       startActivity(new Intent(getApplicationContext(), LoadTaskForEmployee.class));
       finish();

   }

}

LoggedBoss.java

package com.dataflair.advancedcrm;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.google.firebase.auth.FirebaseAuth;

public class LoggedBoss extends AppCompatActivity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_logged_boss);
   }
   public void logout(View view){

       FirebaseAuth.getInstance().signOut();
       startActivity(new Intent(getApplicationContext(), Login.class));
       finish();

   }

   public void AddTask(View view){
       startActivity(new Intent(getApplicationContext(), SaveTask.class));
       finish();
   }

   public void LoadTask(View view){
       startActivity(new Intent(getApplicationContext(), LoadTask.class));
       finish();
   }
   public void AddEmployee(View view){
       startActivity(new Intent(getApplicationContext(), Register.class));
       finish();
   }


}

Employer Home page

employer output

LoggedBoss.java

package com.dataflair.advancedcrm;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.google.firebase.auth.FirebaseAuth;

public class LoggedBoss extends AppCompatActivity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_logged_boss);
   }
   public void logout(View view){

       FirebaseAuth.getInstance().signOut();
       startActivity(new Intent(getApplicationContext(), Login.class));
       finish();

   }

   public void AddTask(View view){
       startActivity(new Intent(getApplicationContext(), SaveTask.class));
       finish();
   }

   public void LoadTask(View view){
       startActivity(new Intent(getApplicationContext(), LoadTaskBoss.class));
       finish();
   }
   public void AddEmployee(View view){
       startActivity(new Intent(getApplicationContext(), Register.class));
       finish();
   }


}

Step 4: Creating Load Task Page for Employer and Employee: This will show the list of pending and completed tasks to the employer and employee. It will show the Employer and Employee, the task progress and task needs to be completed.

load task output

LoadTaskBoss.java

package com.dataflair.advancedcrm;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class LoadTaskBoss extends AppCompatActivity {

   private ListView mListView;

   private FirebaseFirestore db = FirebaseFirestore.getInstance();
   private CollectionReference taskRef = db.collection("Tasks");


   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_load_task);

   }

   @Override
   protected void onStart() {
       super.onStart();
       mListView = findViewById(R.id.listView);


       // Initializing a new String Array
       String[] tasks = new String[]{

       };

       //List of task
       final List<String> task_list = new ArrayList<String>(Arrays.asList(tasks));

       // Create an ArrayAdapter
       final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>
               (this, android.R.layout.simple_list_item_1, task_list);


       mListView.setAdapter(arrayAdapter);

       taskRef.addSnapshotListener(new EventListener<QuerySnapshot>() {
           @Override
           public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
               if (e != null) {
                   return;
               }
               int i = 0;

               //Array initialized for 300 elements;
               final String[] tasksIdArray = new String[300];
               for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                   Task task = documentSnapshot.toObject(Task.class);
                   task.setDocumentID(documentSnapshot.getId());

                   String documentID = task.getDocumentID();
                   String description = task.getDescription();
                   //limiting the description to 20 characters
                   description = description.substring(0, Math.min(description.length(), 70))+ "...";
                   String date = task.getDate();
                   String status = task.getStatus();
                   String company = task.getCompany();


                   tasksIdArray[i] = documentID;
                   i++;

                   task_list.add("Company: " + company + "\n" + "Description: " + description + "\n" + "Date: " + date + "\n" + "Status: " + status);
                   arrayAdapter.notifyDataSetChanged();

               }

               mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                   @Override
                   public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


                       final Intent intent = new Intent(LoadTaskBoss.this, TaskDetails.class);
                       int pos = parent.getPositionForView(view);

                       String taskID = tasksIdArray[pos];
                       intent.putExtra("taskID", "" + taskID);
                       startActivity(intent);
                   }
               });

           }
       });
   }

   public void back(View v) {
       startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
       finish();
   }


}

LoadTaskForEmployee.java

package com.dataflair.advancedcrm;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class LoadTaskForEmployee extends AppCompatActivity {

   private ListView mListView;

   private FirebaseFirestore db = FirebaseFirestore.getInstance();
   private CollectionReference zadaniaRef = db.collection("Tasks");


   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_load_task_for_employee);

   }

   @Override
   protected void onStart() {
       super.onStart();
       mListView = findViewById(R.id.listViewForEmployee);


       // Initializing a new String Array
       String[] tasks = new String[] {
       };

       //List of task
       final List<String> task_list = new ArrayList<String>(Arrays.asList(tasks));

       // Create an ArrayAdapter
       final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>
               (this, android.R.layout.simple_list_item_1, task_list);

       mListView.setAdapter(arrayAdapter);


       zadaniaRef.addSnapshotListener(new EventListener<QuerySnapshot>() {
           @Override
           public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
               if (e != null) {
                   return;
               }
               int i=0;

               //Array initialized for 300 elements;
               final String[] tasksIdArray = new String[300];
               for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                   Task task = documentSnapshot.toObject(Task.class);
                   task.setDocumentID(documentSnapshot.getId());

                   String documentID = task.getDocumentID();
                   String description = task.getDescription();
                   description = description.substring(0, Math.min(description.length(), 70))+ "...";
                   String company = task.getCompany();
                   String date = task.getDate();
                   String status = task.getStatus();

                   tasksIdArray[i]=documentID;
                   i++;

                   task_list.add("Company: " + company + "\n" + "Description: " + description + "\n" + "Date: " + date + "\n" + "Status: " + status);
                   arrayAdapter.notifyDataSetChanged();

               }

               mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                   @Override
                   public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


                       final Intent intent = new Intent(LoadTaskForEmployee.this, TaskDetailsForEmployee.class);
                       int pos = parent.getPositionForView(view);

                       String taskID = tasksIdArray[pos];
                       intent.putExtra("taskID", ""+taskID);
                       startActivity(intent);
                   }
               });

           }
       });
   }
   public void back(View v){
       startActivity(new Intent(getApplicationContext(), LoggedEmployee.class));
       finish();
   }

}

Step 5: Creating Register Page: It will only be visible to the employer. It will be used to register new employees to the app. Only employer can register the employees to the system.

register page output

Register.java

package com.dataflair.advancedcrm;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.FirebaseFirestore;
import java.util.HashMap;
import java.util.Map;

public class Register extends AppCompatActivity {

   EditText mName, mSurname, mEmail,mPassword,mPhone;
   Button mRegisterBtn;
   TextView mLoginBtn;
   FirebaseAuth fAuth;
   ProgressBar progressBar;
   FirebaseFirestore fStore;
   String userID;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_register);

      mName    = findViewById(R.id.regName);
      mSurname = findViewById(R.id.regSurname);
      mPhone   = findViewById(R.id.regPhone);
      mEmail   = findViewById(R.id.regEmail);
      mPassword= findViewById(R.id.regPassword);
      mRegisterBtn = findViewById(R.id.btnRegister);

      fAuth        = FirebaseAuth.getInstance();
      fStore   =FirebaseFirestore.getInstance();
      progressBar  = findViewById(R.id.progressBar);

      //Check that user is logged
       if(fAuth.getCurrentUser() == null){
           startActivity(new Intent(getApplicationContext(), Login.class));
       }

      mRegisterBtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              final String email = mEmail.getText().toString().trim();
              String password = mPassword.getText().toString().trim();
              final String name = mName.getText().toString();
              final String phone = mPhone.getText().toString();
              final String surname = mSurname.getText().toString();

              //register validation
              if (TextUtils.isEmpty(email)){
                   mEmail.setError("Email address required!");
                   return;
              }

              if(TextUtils.isEmpty(password)){
                  mPassword.setError("Password required!");
                  return;
              }

              if(password.length()<6){
                  mPassword.setError("Password must be at least 6 characters long!");
                  return;
              }

              //Set progressbar visible
              progressBar.setVisibility(View.VISIBLE);

               //Register the user
               fAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                   @Override
                   public void onComplete(@NonNull Task<AuthResult> task) {
                       if(task.isSuccessful()){
                           Toast.makeText(Register.this, "Employee Added", Toast.LENGTH_SHORT).show();


                               //Save user data in collection "users"
                               userID = fAuth.getCurrentUser().getUid();
                               DocumentReference documentReference =fStore.collection("users").document(userID);
                               Map<String, Object> user = new HashMap<>();
                               user.put("mName", name);
                               user.put("mSurname",surname );
                               user.put("email", email);
                               user.put("phone", phone);

                               documentReference.set(user).addOnSuccessListener(new OnSuccessListener<Void>() {
                                   @Override
                                   public void onSuccess(Void aVoid) {
                                       Log.d("TAG", "Success! The profile was created for the user "+userID);
                                   }
                               });



                           startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
                       }
                       else{
                           Toast.makeText(Register.this, "An error has occurred" + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                       }
                   }
               });

          }
          });
   }
   public void back(View v){
       startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
       finish();
   }
}

Step 6: Creating Task Page: It will allow the employer to create the new tasks for the employees. Employer will write the description of the task and client details.

task page output

SaveTask.java

package com.dataflair.advancedcrm;
import java.text.SimpleDateFormat;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.FirebaseFirestore;
import java.util.Date;
import java.util.Locale;

public class SaveTask extends AppCompatActivity {


   private EditText editTextCompany;
   private EditText editTextAddress;
   private EditText editTextPhone;
   private EditText editTextDescription;

   private FirebaseFirestore db = FirebaseFirestore.getInstance();
   private CollectionReference tasksRef = db.collection("Tasks");


   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_save_task);

       editTextCompany =findViewById(R.id.edit_text_company);
       editTextPhone =findViewById(R.id.edit_text_phone);
       editTextAddress =findViewById(R.id.edit_text_adress);
       editTextDescription =findViewById(R.id.edit_text_description);
   }

   public void saveJob(View v){
       String company = editTextCompany.getText().toString();
       String address = editTextAddress.getText().toString();
       String phone = editTextPhone.getText().toString();
       String description = editTextDescription.getText().toString();
       String date = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.getDefault()).format(new Date());
       String status="Incomplete";

       if (TextUtils.isEmpty(company)){
           editTextCompany.setError("Company name required!");
           return;
       }
       if (TextUtils.isEmpty(address)){
           editTextAddress.setError("Address required!");
           return;
       }
       if (TextUtils.isEmpty(phone)){
           editTextPhone.setError("Phone number required!");
           return;
       }
       if (TextUtils.isEmpty(description)){
           editTextDescription.setError("Job Description required!");
           return;
       }

       Task task =  new Task(company, address, phone, description, date,status);

       tasksRef.add(task).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
           @Override
           public void onSuccess(DocumentReference documentReference) {
               Toast.makeText(SaveTask.this, "Task has been added", Toast.LENGTH_SHORT).show();
               startActivity(new Intent(getApplicationContext(), LoadTaskBoss.class));
           }
       })
               .addOnFailureListener(new OnFailureListener() {
                   @Override
                   public void onFailure(@NonNull Exception e) {
                       Toast.makeText(SaveTask.this, "An error has occurred", Toast.LENGTH_SHORT).show();
                   }
               });
   }


   public void back(View v){
       startActivity(new Intent(getApplicationContext(), LoggedBoss.class));
       finish();
   }

}

Step 7: Creating Employer’s Task Detail Page: It will show the Entire Detail of the Project to the Employer. Employer can delete the task from this page.

task detail output

TaskDetail.java

package com.dataflair.advancedcrm;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;


public class TaskDetails extends AppCompatActivity {
   TextView mTextView;

   private FirebaseFirestore db = FirebaseFirestore.getInstance();
   private CollectionReference tasksRef = db.collection("Tasks");


   @Override
   protected void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_task_details);
       mTextView = findViewById(R.id.taskDetails);

       mTextView.setMovementMethod(new ScrollingMovementMethod());

       final String id = getIntent().getStringExtra("taskID");


       tasksRef.document(id).addSnapshotListener(new EventListener<DocumentSnapshot>() {
           @Override
           public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {

               if(documentSnapshot.exists()) {
                   Object object = documentSnapshot.getData();

                   final ObjectMapper mapper = new ObjectMapper();
                   final Task task = mapper.convertValue(object, Task.class);

                   String company = task.getCompany();
                   String address = task.getAddress();
                   String phone = task.getPhone();
                   String description = task.getDescription();
                   String date = task.getDate();
                   String status = task.getStatus();


                   String data = "Description: " + description +"\n\nCompany name: " + company + "\nAddress: " + address + "\nContact No.: " + phone + "\nDate Added: " + date+ "\nStatus: "+status;
                   mTextView.setText(data);
               }
               else{

               }

           }
       });

   }

   public void delete(View v){
       final String id = getIntent().getStringExtra("taskID");
       tasksRef.document(id).delete();

       Toast.makeText(this, "Task removed!", Toast.LENGTH_SHORT).show();
       startActivity(new Intent(getApplicationContext(), LoadTaskBoss.class));
       finish();
   }

   public void back(View v){
       startActivity(new Intent(getApplicationContext(), LoadTaskBoss.class));
       finish();
   }

}

Step 8: Creating Employee’s Task Detail Page: It will show the Entire Detail of the Project to the Employees. Employees can update the status of the task from this page.

employee detail task output

TaskDetailsForEmployee.java

package com.dataflair.advancedcrm;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;


public class TaskDetailsForEmployee extends AppCompatActivity {
   TextView mTextView;

   private FirebaseFirestore db = FirebaseFirestore.getInstance();
   private CollectionReference tasksRef = db.collection("Tasks");


   @Override
   protected void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_task_details_for_employee);
       mTextView = findViewById(R.id.taskDetailsForEmp);
       mTextView.setMovementMethod(new ScrollingMovementMethod());

       final String id = getIntent().getStringExtra("taskID");
       if(id!= null) {
           tasksRef.document(id).addSnapshotListener(new EventListener<DocumentSnapshot>() {
               @Override
               public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
                   if (e == null) {
                       if (documentSnapshot.exists()) {
                           Object object = documentSnapshot.getData();

                           final ObjectMapper mapper = new ObjectMapper();
                           final Task task = mapper.convertValue(object, Task.class);

                           String company = task.getCompany();
                           String address = task.getAddress();
                           String phone = task.getPhone();
                           String description = task.getDescription();
                           String date = task.getDate();
                           String status = task.getStatus();


                           String data = "Description: " + description + "\n\nCompany name: " + company + "\nAddress: " + address + "\nContact No.: " + phone + "\nData Added: " + date + "\nStatus: " + status;
                           mTextView.setText(data);
                       }
                   }

               }
           });
       }
   }

   public void delete(View v){
       final String id = getIntent().getStringExtra("taskID");
       tasksRef.document(id).delete();

       Toast.makeText(this, "Task removed!", Toast.LENGTH_SHORT).show();
       startActivity(new Intent(getApplicationContext(), LoadTaskBoss.class));
       finish();
   }


   public void done(View v){
       final String id = getIntent().getStringExtra("taskID");
       tasksRef.document(id).update("status","Completed");
       Toast.makeText(this, "Status changed to: Completed", Toast.LENGTH_SHORT).show();

   }

   public void undone(View v){
       final String id = getIntent().getStringExtra("taskID");
       tasksRef.document(id).update("status","Incomplete");
       Toast.makeText(this, "Status changed to: Incomplete", Toast.LENGTH_SHORT).show();

   }

   public void back(View v){
       startActivity(new Intent(getApplicationContext(), LoadTaskForEmployee.class));
       finish();
   }

}

Android CRM App Output

android project advanced crm output

project advanced crm output

advanced crm output

android advanced crm output

Summary

Congratulations, you have successfully created an Advanced CRM Android app that enables employers to create tasks, delete tasks, and register new users to the app. Employees can view the tasks assigned to them and update their status, whether they are complete or incomplete.

Throughout this project, you learned how to set up a new Android project, design the user interface, implement the functionality to create tasks, delete tasks, and register new users, and enable employees to view and update the status of their tasks.

With the knowledge you’ve gained from this project, you can customize the app to fit your personal or professional needs or use the concepts you’ve learned to create new Android apps. You are now equipped with the skills to develop advanced Android apps that streamline communication between various stakeholders in a business or organization.

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

follow dataflair on YouTube

Leave a Reply

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