Giter Club home page Giter Club logo

accident-detection-app's Introduction

EC601Project -- LIFELINE

Repository for all the code and files concerning the Accident Prevention and Detection App (EC601 Product Design). Check out the website at https://sbobhate.github.io/Accident-Detection-App/

Download the App here https://drive.google.com/file/d/0B3m7cX3DgKxeVEdDSWZ4TXdiSU0/view?usp=sharing

Developers

  • Shantanu Bobhate
  • Sanya Kalra
  • Jennifer Goodell
  • Kexuan Cui
  • Xianglin Zhou

Description

For our introuduction to product design course we decided to create an android app that would detect a car accident and alert first responders as well the users primary contacts. The product was aimed towards giving the users and their families a sense of security.

Sceenshots

Here are a few screenshots of the final App

Technologies Used

Android Studio

We used Android Studio to develop the app. It can be downloaded from here.

Firebase

We used Google Firebase to help us conduct user authentication and maintain a backend database for our application. We used the following videos and resources to understand how to incorporate Firebase into our app.

Add the following dependency to the app-level build.gradle file:

  compile 'com.google.firebase:firebase-auth:9.6.1'
  compile 'com.google.firebase:firebase-database:9.6.1'

Code for Firebase Authentication:

  private FirebaseAuth firebaseAuth

  ...

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ...

    firebaseAuth = FirebaseAuth.getInstance();

    /* To Create a new User */
    firebaseAuth.createUserWithEmailAndPassword(email, password)
          .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
              @Override
              public void onComplete(@NonNull Task<AuthResult> task) {
                  progressDialog.dismiss();
                  if (task.isSuccessful()) {
                      // Do something
                  }
                  else
                  {
                      // Display an Error Message
                  }
              }
          });

    ...

    /* To Sign In a User */
    firebaseAuth.signInWithEmailAndPassword(email, password)
          .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
              @Override
              public void onComplete(@NonNull Task<AuthResult> task) {
                  if (task.isSuccessful()) {
                      // Do something
                  }
                  else
                  {
                      // Display an Error Message
                  }
              }
          });
  }

Code for Firebase Database:

  private FirebaseAuth firebaseAuth;
  private DatabaseReference databaseReference;

  ...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      ...

      firebaseAuth = FirebaseAuth.getInstance();

      final FirebaseUser user = firebaseAuth.getCurrentUser();
      if (user == null) {
          finish();
          startActivity(new Intent(this, LoginScreenActivity.class));
      }

      databaseReference = FirebaseDatabase.getInstance().getReference();

      ...

      /* To retrieve data */
      databaseReference.child(user.getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              ArrayList<String> values = new ArrayList<String>(4);
              for (DataSnapshot child : dataSnapshot.getChildren()) {
                  values.add(child.getValue().toString());
              }

              if (!values.isEmpty()) {
                  // Do something with the values
              }
          }

          @Override
          public void onCancelled(DatabaseError databaseError) {
              // Display an Error Message
          }
      });

      /* Write Data */
      UserInformation userInformation = new UserInformation(firstName, lastName, policyNumber, phoneNumber);  
      databaseReference.child(user.getUid()).setValue(userInformation);

      ...
  }

  ...

  public class UserInformation {

      public String firstName, lastName, policyNumber, phoneNumber;

      public UserInformation() {
      }

      public UserInformation(String firstName, String lastName, String policyNumber, String phoneNumber) {
          this.firstName = firstName;
          this.lastName = lastName;
          this.policyNumber = policyNumber;
          this.phoneNumber = phoneNumber;
      }
  }

A Demo for Firebase Authentication on Android:

Google Api

We used the Google Maps Api to collect the users coordinates which we used to track the user's location as well as track the user's velocity. Our app's accident detection mechanism was activated at higher speeds. We also used this api to query the locations and the contacts of the closest hospitals.

Contents

This repository contains 2 android projects:

  • Lifeline
  • DataToCSV

Lifeline

This folder contains all the files for our final app.

DataToCSV

This folder contains all the files for the testing app we created in order to collect acceleration data. We used this data to create the classification model.

accident-detection-app's People

Contributors

sbobhate avatar sanyakalra avatar kexuancui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.