android calculator with math functions

Click here to load reader

Upload: hibbuh

Post on 06-Dec-2015

260 views

Category:

Documents


3 download

DESCRIPTION

This is a Design and Implementation of an Android Calculator with Basic Math Functions.The Project is designed using the Official Android Developer Tool (Android Studio) from Google.The Official Android IDE may be found at http://developer.android.com

TRANSCRIPT

  • Implementation of a Basic Calculator with

    Scientific Functions in Android

    Hibban Buhari

    CST/12/COM/00325

    Faculty of Computer Science and Information Technology

    Department of Computer Science

    Bayero University Kano.

  • ii

    Certification

    This is to certify that the work in the project entitled Implementation of a

    Basic Calculator with Scientific Functions in Android Mobile Devices by

    Hibban Buhari is a SIWES Mini Project work carried out under my

    supervision and guidance in partial fulfillment of the requirements for the

    award of the degree of Bachelor of Computer Science.

    S. H. Muhammad

  • iii

    Acknowledgment

    I would like to use this opportunity to express my humble gratitude to Mal.

    S. H. Muhammad under whom I executed this project. His constant

    guidance and willingness to share his vast knowledge made me understand

    this project and its manifestations in great depths and helped me to

    complete the assigned tasks.

    I would like to thank all Faculty members and sta of the Department of

    Computer Science, B.U.K for their generous help in various ways for the

    completion of this work.

    Finally, yet importantly, I would like to express my heartfelt thanks to my

    beloved parents for their blessings, my friends and classmates for their help

    and wishes for the successful completion of this project.

    Hibban Buhari

  • iv

    Abstract

    Since ages, calculation has been one of the most important way to enable

    human beings compute values in various distinct being it marketing,

    accounting, e.t.c. Calculator plays vital role in the history of mankind

    originating from the Abacus, to the invention of the first electronic

    calculator by Blaise Pascal. This helps individuals and organization in

    computing various number together.

    In this project, an attempt has been made to design in implement a

    scientific-like calculator for mobile devices. The aim of the project is to

    create an Android mobile application for use in carrying out mathematical

    computations that can be used by all. This application receives input from

    the user and performs the required arithmetic operation.

    This application uses Android application development toolkit. Android is

    a Linux-based operating system developed for smartphones or tablet

    computers. It is a stack of software that includes operating system,

    middleware and libraries and APIs written in C. The Android application

    is developed in Java-like language using the Android Software

    Development Kit (SDK). The Integrated Development Environment (IDE)

    which is ocially supported for Android apps development and used in

    this project is Android Studio, it requires no plugin as it is the new

    repository to Android Developers to use, better than Eclipse, which uses

    the Android Development Tools (ADT) plugin.

  • v

    Table of Contents Certification ............................................................................................ ii

    Acknowledgment ................................................................................... iii

    Abstract .................................................................................................. iv

    Chapter 1 ................................................................................................. 1

    Introduction ............................................................................................. 1

    1.1 What is Android? ............................................................................ 1

    1.2 The Android Platform ..................................................................... 2

    1.3 Android Software Stack. ................................................................. 2

    1.3.1 Application Framework ............................................................ 3

    1.3.2 Dalvik Virtual Machine (DVM) ............................................... 3

    1.3.3 SQlite ....................................................................................... 4

    1.3.4 Linux Kernal ............................................................................ 4

    1.3.5 System Libraries and Android Runtime System ....................... 5

    1.3.6 Application Framework Layer .................................................. 6

    1.3.7 Applications & Widgets Layer ................................................. 6

    1.4 Objective ........................................................................................ 7

    Chapter 2 ................................................................................................. 8

    General Description, Requirement Analysis and Specification ................ 8

    2.1 Introduction .................................................................................... 8

    2.2 Product Perspective ........................................................................ 8

    2.3 General Constraints ........................................................................ 8

    2.4 Requirement Analysis ..................................................................... 9

    2.5 Functional Requirements of the System .......................................... 9

    Chapter 3 ............................................................................................... 11

    Design & Implementation ...................................................................... 11

    3.1 Function Oriented Software Design .............................................. 11

    3.2 Object Oriented Software Design ................................................. 11

    3.3 Implementation ............................................................................. 12

    3.4 Android API ................................................................................. 12

    3.5 Graphical User Interface ............................................................... 13

  • vi

    Chapter 4 ............................................................................................... 15

    Conclusions and Future Work ................................................................ 15

    4.1 Conclusion .................................................................................... 15

    4.2 Future Work ................................................................................. 15

    References ............................................................................................. 16

  • 1

    Chapter 1

    Introduction

    Since ages, calculation has been one of the most important way to enable

    human beings compute values in various distinct being it marketing,

    accounting, e.t.c. Calculator plays vital role in the history of mankind

    originating from the Abacus, to the invention of the first electronic

    calculator by Blaise Pascal. This helps individuals and organization in

    computing various number together.

    The design in implements a scientific-like calculator for mobile devices.

    The aim of the project is to create an Android mobile application for use in

    carrying out mathematical computations that can be used by all. This

    application receives input from the user and performs the required

    arithmetic operation.

    1.1 What is Android?

    Android is a Linux-based operating system developed for smart phones or

    tablet computers. It is a stack of software that includes operating system,

    middleware and libraries and APIs written in C. It was developed by

    Google and Open Handset Alliance in July, 2005. Android is an open

    source and Google releases the source code under Apache license. This

    open source and free license allow the manufacturers and the enthusiastic

    developers to freely develop and modify their applications in Java-like

    language that utilizes Google-developed Java libraries.

  • 2

    The Android applications are developed using the Android software

    development kit (SDK). The SDK includes a comprehensive set of

    development tools which includes a debugger, software libraries, a handset

    based emulator which is based on QEMU (Quick EMUlator) and tutorials.

    The integrated development environment (IDE) which is ocially

    supported for Android apps development is Eclipse which uses the

    Android Development Tools (ADT) plugin. The following are the several

    features which help in the development of Android applications:

    1.2 The Android Platform

    The Android Platform is a software stack designed primarily but not

    exclusively to support mobile devices such as phones and tables.

    The stack has several layers. The layers ranges from low level operating

    system services that manages the device and its configurations up to

    sample Applications like Phone Dialer, Contacts Database and Web

    Browser. Android software also comes with a Software Developers Kit,

    SDK, used to create Android Applications.

    1.3 Android Software Stack.

    The Android software stack is organized into several layers as follows:

    1. Linux Kernel Layer;

    2. System Libraries and Android Runtime System;

    3. Application Framework Layer; and

    4. Standard Applications Layer.

  • 3

    1.3.1 Application Framework

    Android application framework is supported by number of open source

    libraries like OpenSSL, SQLite, and Libc. The application framework is

    also supported by the Android core libraries. The framework is based on

    UNIX file system permissions which ensures security as the applications

    can have only those abilities that mobile phone owner give at the time of

    installation. The application framework enables the reuse and replacement

    of components.

    1.3.2 Dalvik Virtual Machine (DVM)

    Dalvik is a process virtual machine used in Googles Android operating

    system. It is a low memory based virtual machine which is especially

    designed for Android to run on the embedded systems and work eciently

    in low power. The programs are commonly written in Java and are

    compiled into bytecode. This bytecode is then converted form JVM .class

    files to .dex file (Dalvik executable) before installation on a device.

    Fig1.1: Dalvik VM Conversion

  • 4

    1.3.3 SQlite

    Android OS contains the SQLite database management classes which is

    used by an application to maintain its own private database. SQLite is a

    relational database management system contained in C programming

    library. It is mostly preferred as embedded database for local or client

    storage in application software. It has many bindings to the programming

    languages.

    1.3.4 Linux Kernal

    The Linux Kernel Layer is the lowest layer of software in the Android

    Platform. It provides core services that Android computing devices rely on

    and generic operating system services.

    These services include:

    a. permission architecture to restrict access to data and resources to

    processes that have proper authorization;

    b. memory and process management to enable multiple processes run

    simultaneously without interfering with each other; and

    c. device drivers to enable Android communicate with the wide range

    low-level hardware components that can couple with computing

    devices such as memory, camera.

    Android Linux Kernel also has some specific components. These are but

    not limited to:

    a. Android Linux Kernel includes built in power management to enable

    mobile device run on battery power;

  • 5

    b. it also has built-in memory sharing and memory management

    features because of the limited memory of mobile devices;

    c. it also includes inter-process communication mechanism called

    binder to allows multiple processes and services share resources in

    sophisticated ways.

    1.3.5 System Libraries and Android Runtime System

    The system libraries often referred to as the native library are written in C

    and C++. They handle a lot of core performance sensitive activities on

    Android devices.

    The Android libraries has built-in system C library handling process and

    thread creation, mathematical computation, and memory allocation, also,

    the System Libraries include:

    i. the Surface Manager for managing and updating the display;

    ii. the Media Framework used for playing back Audio and Video files;

    iii. the WebKit for rendering Browser and opening WebPages;

    iv. Open GL for high performance graphics; and

    v. SQLite for managing in-memory relational database engine.

    In addition to the System Libraries, the layer also includes the Android

    Runtime which supports writing and running Android applications.

    The Android Runtime System has two main components i.e. the Core Java

    Libraries and the Dalvik Virtual Machine.

  • 6

    1.3.6 Application Framework Layer

    The Application Framework Layer contains reusable softwares that many

    Mobile Applications may likely need e.g. the View System (contains text,

    buttons, e.t.c.).

    These include:

    Package Manager;

    Window Manager;

    View System;

    Resource Manager;

    Activity Manager;

    Location Manager;

    Notification Manager.

    1.3.7 Applications & Widgets Layer

    Android OS come with some built in Applications in the Mobile Devices.

    The Applications & Widgets Layer is the highest layer in the architectural

    diagram of Android layers. The layer handles the built in Applications

    which include the standard applications that can take over the whole screen

    and interact with the user comprising the Home Screen, the Contacts

    Database, the Phone Dialer, the Web Browser, Email Reader, e.t.c. End

    users will only see these programs.

    On the other hand, Widgets (sometimes called gadgets) only operate in a

    small rectangle of the Home Screen application. One advantage of the

    Android Application & Widgets Layer is that these standard Applications

    are not hard-coded in the device. A developer may substitute an

  • 7

    Application with his own 3rd party Application that he feels is a better

    Application.

    Figure 1.2: Growth Chart for the android OS

    Nowadays, Android phones have emerged as the worlds most popular

    mobile platform. Its the largest installed base of any mobile platform and

    growing fast. Millions of users are using android phones and android

    applications are becoming more and more popular.

    1.4 Objective

    Design a Calculator to use to perform basic arithmetic computations for

    mobile devices for easy and proper evaluation of computation.

    1. Develop and implement a Calculator.

    2. To create an Android mobile application that provides a User

    Interface to interact with the system.

  • 8

    Chapter 2

    General Description, Requirement Analysis and Specification

    2.1 Introduction

    The calculator system gives an ease in the working and performing

    mathematical functions of the system in an easy way through an intuitive

    interface that makes it easy for user to tap on using the rich gesture facility

    of Android Operating System

    2.2 Product Perspective

    The Calculator System simplifies computations of our day-to-day activities

    using our mobile devices. The system can be deployed on every mobile

    device running the Android OS. The software focus on the easy way of

    conducting mathematical computations with the use of mobile phones.

    2.3 General Constraints

    The general constraints of this system are of two types

    1. Hardware Constraints

    2. Software constraints

    Any devices which can run Android Operating System. And the following

    are the software constraints of the system.

  • 9

    2.4 Requirement Analysis

    The Application developed follows the following steps of Software

    Development Lifecycle. The System Requirement Specification model

    developed for the system is as listed below

    The SRS model Contains

    Functional Requirements.

    Non-Functional requirements

    2.5 Functional Requirements of the System

    The functional requirements part discuss the functional behavior that should

    be possessed by the system. Each requirement maps to a high level function

    that transforms the given set of input data into output data.

    Dierent functional requirements possessed by the system are:-

    Activity_main.xml

    Description: The xml file containing the user interface of the system.

    Users would be presented with an interface to interact with through

    their mobile phones.

    FirstActivity.java

    Description: The file containing the Java declaration and expression

    files. The MainActivity.java is a class that extends the Activity class

    and implements various methods contained in the Activity class.

  • 10

    Splash.xml

    Description: The xml file containing the Splash Screen user interface

    of the system. This activity runs for 5 seconds providing the user with

    the devices date and time and calls the First Activity.

    Splash.java

    Description: The file containing the Java declaration and expressions

    for the Splash.xml. The Splash.java is a class that extends the Activity

    class inherits the FirstActivity and implements various methods

    contained in the Activity class.

    It also uses an Intent method used in the Activity class in Android to

    request functionality from other Android components.

  • 11

    Chapter 3

    Design & Implementation

    The design phase emphasizes on the transformation of user requirements as

    defined in the SRS document, into a form that is suitable for coding.

    The design phase can be broadly classified in two levels.

    Preliminary or high level design

    Detailed design

    The preliminary design can be further divided into two sub categories

    Function Oriented Software Design

    Object Oriented Software Design

    3.1 Function Oriented Software Design

    This design model can be represented by drawing the DFDs (Data Flow

    Diagrams) for the given SRS document.

    A data flow diagram is a graphical representation of the data flow through an

    information system which is used to model the process aspects of the system.

    DFD is the preliminary step used to create an overview of the system. DFD is

    used for structured design.

    3.2 Object Oriented Software Design

    In this design approach the system is viewed as a collection of entities

    (objects). Each object manages its own properties (attributes) and state.

  • 12

    3.3 Implementation

    The Application is implemented according to three tier architecture. Three tier

    architecture is commonly known as Client-Server architecture, where Client

    is the consumer of the services, also the requester of services whereas the

    server side is the provider of services. The third layer that is the middle layer

    that converts the users requests into server understandable form.

    The system developed contains Android application in its front end ie the

    client side. The middle layer that connects the client side to the server side is

    the Jason (JavaScript Object Notation) Parser that is primarily used to transmit

    data between server and server application.

    3.4 Android API

    API stand for Application Programming Interface. It contains the following

    features-

    Applications are written in Java;

    The source code file is compiled into Java Bytecode file;

    DX converts the Java Bytecode file to single Dex Bytecode file;

    The Dex file is then packaged with other Application resources and

    installed on the Device;

    And finally, when the user launches the Application, the Dalvik Virtual

    Machine executes the Dex file.

  • 13

    3.5 Graphical User Interface

    The application GUI is developed using the android SDK and the various

    forms are as shown below.

    Fig. 3.3: Startup Splash Screen

    Fig. 3.1: Android API Debug process

    Fig. 3.2: Launcher Icon

  • 14

    Fig 3.4: Main Activity

    Fig 3.5: Result from

    Evaluation

  • 15

    Chapter 4

    Conclusion and Future Work

    4.1 Conclusion

    The Calculator for mobile devices is a very effective tool which can be used

    to a great extent. The system is portable and can be easily installed and used

    on any mobile phones supporting Android OS.

    The use of this system can result in a reduction of number of time spent

    computing values. It also provides an interface which is easy to understand by

    the users and greatly helps in adapting to the use of this system.

    4.2 Future Work

    The system can be further enhanced and several other functionalities can be

    added. The system can be made to send result to an output file, generate log

    and usage statistics, and can be made to retrieve the generated log activity.

    The present system prints to the stack usage logs and statistics.

    The system can also be enhanced by using voice recognition feature of the

    Android.

  • 16

    References

    Android Developers. (2014, December 6). Creating an Android Project. Retrieved from Android Developers Training: https://developer.android.com/training/basics/firstapp/creating-project.html

    Lars Vogel. (2014, December 28). Vogella. Retrieved from Android Development: http://www.vogella.com

    Murphy, M. L. (2009 - 2011). Android Programming Tutorials. United State of America: CommonsWare.

    Travis. (n.d.). Android Application Development Tutorial. Retrieved from http://www.travis.com