Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, 25 November 2015

AcidSQL Application Avaiable on Google Play Store

What is ACID ?

Database ACID (Atomicity, Consistency, Isolation, Durability) Properties


There are a set of properties that guarantee that database transactions are processed reliably, referred to as ACID (Atomicity, Consistency, Isolation, Durability).

Atomicity

Atomicity refers to the ability of a database to guarantee that either all of the tasks are performed or none of them are. Database modifications must follow an all or nothing rule. Each transaction is said to be atomic if when one part of the transaction fails, the entire transaction fails.

Consistency

The consistency property ensures that the database remains in a consistent state before the start of the transaction and after the transaction is over.

A distributed data system is either strongly consistent or has some form of weak consistency

Weak consistency is sometimes referred to as eventual consistency, the database eventually reaches a consistent state. Weak consistency systems are usually ones where data is replicated; the latest version is sitting somewhere in the cluster, older versions are still out there. Eventually all nodes will see the latest version.

Isolation

Isolation refers to the requirement that other operations cannot access or see the data in an intermediate state during a transaction. This constraint is required to maintain the performance as well as the consistency between transactions in a database.

Durability

Durability refers to the guarantee that once the user has been notified of success, the transaction will persist, and not be undone. This means it will survive system failure, and that the database system has checked the integrity constraints and won't need to abort the transaction.

Durability does not imply a permanent state of the database. Another transaction may overwrite any changes made by the current transaction without hindering durability.


With the AcidSQL App you can can connect to databases, make queries, execute SQL commands
view results grpahically, show tables. edit registers, delete registers and tables, view database, specifications


AcidSQL is compatible with Microsoft SQL Server, MySQL and PostgreSQL databases.

Click on the link to download now on your Android device.

Get it on Google Play

Thursday, 25 June 2015

Dr Hearing Open Source Project

Disclaimer: the following post contains extracts from my final year thesis and may not be re-used in any form or fashion without my permission, thank you for reading..









Project DHOSP - What is DHOSP?
Dr Hearing Open Source Project was my final year project which was designed to identify hearing impairments in adults. The project was completed but lacked a production quality standard for publication, so apart of my project scope was to bring the project to my fellow colleagues and developers so that we may develop the best Android application for identifying hearing deficiencies.

So what is a hearing test?

A hearing test provides a methodology to diagnose an individual’s hearing impairment or deficiencies. ISO 8253-1:2010 is an international standard for PTA (Pure Tone Audiometry). This standard specifies procedures and requirements for PTA air conduction and bone conduction. Pure tone audiometry is the measurement of an individual’s hearing across a range of test frequencies using a standardized test method that specifies the procedure for determining the threshold, the range of test frequencies and presentation levels, and the way thresholds are presented in a graphical manner and including the symbols user to depict objects. We use PTA to evaluate possible hearing losses and to determine the type of hearing loss that an individual may have.



Hearing loss can be defined as the amount a person’s hearing level changes as a result of some adverse influence. This means that some structure or function of the ear that is crucial to hearing has been damaged.


There are three main forms of hearing loss; Sensor neural affecting the cochlea, Conductive hearing loss affecting the ear canal and mixed hearing loss which is a combination of both sensor neural and conductive hearing loss.


The World Health Organization (WHO) defines “disabling hearing impairment in adults as a permanent unaided hearing threshold level (average for frequencies 0.5, 1, 2, 4 kHz) for the better ear of 41 dB or greater (WHO, 2001).2 In children under 15 years of age, disabling hearing impairment is defined as permanent unaided hearing threshold level (average for frequencies 0.5, 1, 2, 4 kHz) for the better ear of 31 dB or greater.”


The auditory pathway includes the external ear, the middle ear and the inner ear, followed by the auditory nerve ending up in the auditory centres in the auditory cortex.




· The external ear consists of the pinna, ear canal and eardrum. Sound travels down the ear canal, through the eardrum and causing it to move or vibrate.


· The middle ear is a space behind the eardrum that contains three small bones called ossicles. This string of tiny bones is connected to the eardrum at one end and to the oval window at the other end which connects to the inner ear. Vibrations from the eardrum cause the ossicles to vibrate which, in turn, creates movement of the fluid in the inner ear.


· Movement of the fluid in the inner ear, or cochlea, causes changes in hair cells. This movement of the hair cells sends electric signals from the inner ear up the auditory nerve to the brain.


What is an Audiogram?



An audiogram plots decibel (dB) values on the Y-Axis. If a loss of hearing is present then the graph will have higher points with increased dB signal where the person is having difficulty hearing the tone. The more severe the hearing loss the more the dB values on the graph will going downwards. On the X-Axis we have the plotting of the frequency pure tones in hertz (Hz). An Audiogram usually plots sound on the left lowest 125Hz and increasing to 8000 KHz.

Purpose of the Project
The purpose of this project was to develop an application that would help identify common hearing impairment by using an audiogram which would picture how a person hears. The audiogram is used to describe the hearing of a person across different frequencies. It can be used as a tool to determine amount of damage done or determine the cause.

Goal of the Project
The goal of the project was to develop and application to determine hearing impairments in adults.

Motivation
An easy and simple application that will allow users to quickly do hearing tests for an assessment, where they get results by reading the audiogram.

Considerations
The problem of hearing impairment is an increasing problem across most populations of the world and is something that people should be aware of and by taking hearing tests they can be made more aware of their own level of hearing and how to best keep it healthy. In the EU it is estimated that more than 55 million people are having hearing impairments and the costs in the EU is estimated to 160 billion Euros per year. According to a study, a mild hearing loss costs 2000 euros per individual each year, a moderate costs 6,600 and severe 11,000 euros.

From the above studies we can see that it is a problem that needs to be carefully analyzed and more research needs to be done.

Measurement
The advantage brought to users through this application is that it provides free and quick self-test ability. Where-as many Android applications or web applications require connection to the internet using databases, this current project does all processing locally on the users device.






System Implementation


Android Activities
An activity represents a single screen that the user sees on the device. An application usually consists of multiple activities. Activities are the most observable part of the application. In Android, you can be looking at an activity of one application, but shortly after you could start another activity in a completely separate application. For example, if you are in the Calendar application and you decide to call a friend, you would be launching the activity to bring up the phone application in the Calendar application.


Android life-cycle
Activity can be expensive on the device CPU and RAM. It can sometime involve creating a new Linux process, allocating memory for all the new objects, inflating the objects from XML layouts, and setting up the screen. In Android the activity life cycle is managed by the Activity Manager.

Activity Manager is responsible for creating, destroying, and managing activities. For example, when the user starts an application for the first time, the Activity Manager will create its activity and put it onto the screen. Later, when the user switches screens, the Activity Manager will move that previous activity to a holding place. This way, if the user wants to go back to an older activity, it can be started more quickly. Older activities that the user hasn’t used in a while will be destroyed in order to free more space for the currently active one. This mechanism is designed to help improve the speed of the user interface and thus improve the overall user experience.

Programming for Android is conceptually different than programming for some other environments. In Android, you find yourself responding more to certain changes in the state of your application rather than driving that change yourself. It is a managed, container-based environment similar to programming for Java applets or servlets. So, when it comes to an activity life cycle, you don’t get to say what state the activity is in, but you have plenty of opportunity to say what happens during the transitions from state to state. The figure below shows the states that an activity can go through.



Managing the lifecycle of activities by implementing call-back methods is crucial to developing a strong application. The lifecycle of an activity is directly affected by its association with other activities,

Call-back methods are essentially in the three states as follows:

1. Resumed

The activity is in the foreground of the screen and has user focus.

2. Paused

Another activity is in the foreground and has focus, but this one is still visible. That is, another activity is visible on top of this one and that activity partially transparent,

3. Stopped

The activity is completely hidden by another activity. Figure 26 Diagram of how the methods are called for each button



Each button has as onClick() method which the is specified in the XML file. Once button is clicked, an intent object is created which takes instance of current class and class to be launched. Intents provide the ability to bind classes together which helps us to launch them along.

Another important aspect to activities is declaring them in the Android Manifest because if not declared the application will crash with an exception error. In the Manifest we use an activity tag and pass in location of class in the project package




Implementing Frequency Generator
Generating the pure tone requires the use of basic sine wave. In the Frequency Generator class we create an array of generated sound samples and pass it into the AudioTrack.write function. This function takes data to the audio sink for playback in streaming mode. The byte class is used as it wraps primitive value byte in an object. The encoding scheme is PCM 16 bits per sample. Pulse code modulation encodes an audio waveform in the time domain. The frequency and sample rate measures how many samples are plated each second. We use getChannelConfiguration which return the configured channel configuration



The encoding plays an important role as the byte array is in played in form of audio. The audio track write method takes in three parameters one is the byte array this is the audio data, second is the offset bit and last is the size of the bytes.

We create an object of type short which is a 16-bit signed two’s complement integer. The short class wraps a value of primitive type in an object

Configuring the sample rate 44,100 gives the highest quality sound. We test each pure tone and compare if it sounds is as good.




Implementing Audiogram with Android plot library
In order to render the audiogram we require a comprehensive library to create our audiogram. There are two most popular open source libraries available, both were tried and tested, these included AndroidPlot and GraphView.



After testing both GraphView and AndroidPlot, the latter was more useful as it contained helpful examples and its source code was more understandable. To implement AndroidPlot within the project first we have to include it within the project build path.



The main audiogram is implemented into the HearingTestActivity class. This class contains a method to render XYPlot which we associate with out XYPlot which we declared in our audiogram XML file. We create a reference object of type XYPlot this contains information for the plot XY axis and colour of background. This XYPlot class further inherits from XYSeries, XYSeriesFormatter and XYSeriesRenderer. These are all interfaces or abstract classes which provide impartial or no implementation.




Implementing Fragments
Fragments in android can be described as an activity within an activity. Fragments were chosen as a way to combine multiple activities was required which had different classes acting on single screen view. In the design two fragments were added to one layout view that is the HearingTestActivity. In order to implement this, first a layout view was created for the playtone_fragment this is where the user controls the testing options. The other fragment is then of the audiogram which only draws a XYPlot using the Android plot library. The two fragments are then combined into one layout, the reason for doing this is that we can separate the logic of both classes to their own respected layouts and that once we embed them as fragments, the code is less coupled and not totally dependent on other methods .

The implementation of the fragments was one of the trickiest aspects of the project as it took me a long time to implement. There many of ways to implement fragments a there is no best solution so it was trial and error to discover which method worked best. The method that worked for me was where we had fragments tags declared in the hearing test layout and have a class tag defined and also a tools tag for each fragment. The tools tag defines which layout is rendered and is very important.


To complete the implementation of fragments we create two classes for each xml file. These two classes contain an onCreateView method which inflates the layout into the hearingtest_view.xml activity. The inflater instantiates a layout XML file into the View object. The inflation uses XML file at build time. Last thing to make sure is to include the android-support-v4.jar file in the project build path.



Become a member of Team DHOSP

Link to the project repository : https://github.com/JunSoftware109/AndroidProjectHearing

If you would like to be an official contributor contact me at junmalik109@gmail.com.
I will then have a chat with you and welcome you to the team.

Thanks for reading and goodbye for now!


Sunday, 16 November 2014

Android Calculator App

Hello,
This is my first Android application made in Eclipse Juno in Windows 7. It is a simple calculator with elementary mathematical operations it was designed as an application for a  generic 7" tablet.




The below is the code for the layout xml file:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/green" >

   <LinearLayout
        android:id="@+id/row1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".12" >
        
 
        <TextView
            android:id="@+id/displayBox"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="right"
            android:maxLines="1"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:text="0"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="70sp" />
    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/row3"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".12" >
 
        <Button
            android:id="@+id/button_cancel"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_cancel"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button_point"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_point"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button_divide"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_divide"
            android:textSize="45sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button_mult"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_mult"
            android:textSize="45sp"
            android:textStyle="bold" />

    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/row4"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".12" >
 
        <Button
            android:id="@+id/button7"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button7"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button8"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button8"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button9"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button9"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button_sub"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_sub"
            android:textSize="45sp"
            android:textStyle="bold" />

    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/row5"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".12" >
 
        <Button
            android:id="@+id/button4"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button4"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button5"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button5"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button6"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button6"
            android:textSize="35sp"
            android:textStyle="bold" />
 
        <Button
            android:id="@+id/button_add"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_add"
            android:textSize="45sp"
            android:textStyle="bold" />

    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/row6"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".24"
        android:baselineAligned="false" >
 
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".75"
            android:orientation="vertical" >
 
            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight=".50"
                android:textSize="25sp" >
 
                <Button
                    android:id="@+id/button1"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight=".33"
                    android:text="@string/button1"
                    android:textSize="45sp"
                    android:textStyle="bold" />
 
                <Button
                    android:id="@+id/button2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight=".33"
                    android:text="@string/button2"
                    android:textSize="35sp"
                    android:textStyle="bold" />
 
                <Button
                    android:id="@+id/button3"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight=".34"
                    android:text="@string/button3"
                    android:textSize="35sp"
                    android:textStyle="bold" />

            </LinearLayout>
 
            <LinearLayout
                android:id="@+id/linearLayout2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight=".50" >
 
                <Button
                    android:id="@+id/button0"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight=".66"
                    android:text="@string/button0"
                    android:textSize="35sp"
                    android:textStyle="bold" />

            </LinearLayout>
        </LinearLayout>
 
        <Button
            android:id="@+id/button_equals"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".25"
            android:text="@string/button_equals"
            android:textSize="45sp"
            android:textStyle="bold" />

    </LinearLayout>
 
</LinearLayout> 
 
 
 
 
 
The following is code for the Main Activity class
 

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
package com.Junaid.calculator; //this is main package name

import com.Junaid.calculator.R;//we import .R file contained in main package
import android.app.Activity;//resources containing Activity
import android.os.Bundle;//resources containing os.Bundle
import android.view.Menu;//resources containing menu
import android.view.View;//resources containing View
import android.view.View.OnClickListener;//resources containing onClickListener
import android.widget.Button;//resources containing Button
import android.widget.TextView;//resources containing TextView

//MainActivity inherits from Activity main class and implements onClickListener interface
public class MainActivity extends Activity implements OnClickListener {
 // Activity Data declaration
 static char previousOp = '+';//static variable only exists in one copy and belongs to class
 static float runningTotal = 0;//static variable only exists in one copy and belongs to class
    static int TRUE = 1;//static variable only exists in one copy and belongs to class
    static int FALSE = 0;//static variable only exists in one copy and belongs to class
    static int newvalue = TRUE;//static variable only exists in one copy and belongs to class
    //We create private variables that hold reference of button objects
 private Button button0, button1, button2, button3, button4, button5, button6,
       button7, button8, button9, button_point, button_add, button_cancel,
       button_sub, button_mult, button_divide, button_equals;
 private TextView displayBox;//private instance of Textview we create displayBox reference
 //every activity must implement abstract method onCreate
 //this method gets called once Activity is started
 //savedInstanceState is used to retrieve state from an activity before being killed
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  CharSequence text;//Interface CharSequence represents ordered set of characters and defines the methods invoke them. 
  super.onCreate(savedInstanceState);//overridden method is accessed even within subclass
  setContentView(R.layout.activity_main);
  //Run the function findViewById and pass it R.id.button7 as parameters
  button7 = (Button)findViewById(R.id.button7);
  button7.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button8 as parameters
  button8 = (Button)findViewById(R.id.button8);
  button8.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button9 as parameters
  button9 = (Button)findViewById(R.id.button9);
  button9.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button4 as parameters
  button4 = (Button)findViewById(R.id.button4);
  button4.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button5 as parameters
  button5 = (Button)findViewById(R.id.button5);
  button5.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button6 as parameters
  button6 = (Button)findViewById(R.id.button6);
  button6.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button0 as parameters
  button0 = (Button)findViewById(R.id.button0);
  button0.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button1 as parameters
  button1 = (Button)findViewById(R.id.button1);
  button1.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button2 as parameters
  button2 = (Button)findViewById(R.id.button2);
  button2.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button3 as parameters
  button3 = (Button)findViewById(R.id.button3);
  button3.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_point as parameters
  button_point = (Button)findViewById(R.id.button_point);
  button_point.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_equals as parameters
  button_equals = (Button)findViewById(R.id.button_equals);
  button_equals.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_add as parameters
  button_add = (Button)findViewById(R.id.button_add);
  button_add.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_sub as parameters
  button_sub = (Button)findViewById(R.id.button_sub);
  button_sub.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_mult as parameters
  button_mult = (Button)findViewById(R.id.button_mult);
  button_mult.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_divide as parameters
  button_divide = (Button)findViewById(R.id.button_divide);
  button_divide.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.button_cancel as parameters
  button_cancel = (Button)findViewById(R.id.button_cancel);
  button_cancel.setOnClickListener(this);//if button clicked onClickListener runs corresponding onClick() method
  //Run the function findViewById and pass it R.id.displayBox as parameters
  displayBox = (TextView)findViewById(R.id.displayBox);
  text = "0";//text of in display is set to 0
  displayBox.setText(text);//run function getText belonging to displayBox and pass it text 
 }//End of overridden onCreate method
 
 //onClick method gets called each time a button is pressed
 public void onClick(View v) {
  //CharSequence is an interface
  CharSequence text; //A CharSequence is a readable sequence of char values
  //Find out which button was pushed based on its ID
  //Switch statement checks for which button was checked and changes that text
  switch(v.getId()) { 
   case R.id.button7: {
    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("7");//run function setText belonging to displayBox and pass string of 3
                 newvalue = FALSE; //the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox in set it to text
              text = text + "7";//add 7 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and set it to text
             }
    break;//Exit the loop
   }
   
   case R.id.button8: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("8");//run function setText belonging to displayBox and pass string of 8
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox in set it to text
              text = text + "8";//add 8 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and set it to text
             }
    break;//Exit the loop
   }
   
   case R.id.button9: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("9");//run function setText belonging to displayBox and pass string of 9
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox in set it to text
              text = text + "9";//add 9 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button4: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("4");//run function setText belonging to displayBox and pass string of 4
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "4";//add 4 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button5: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("5");//run function setText belonging to displayBox and pass string of 5
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "5";//add 5 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button6: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("6");//run function setText belonging to displayBox and pass string of 6
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "6";//add 6 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button0: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("0");//run function setText belonging to displayBox and pass string of 0
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "0";//add 0 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button1: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("1");//run function setText belonging to displayBox and pass string of 1
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "1";//add 1 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button2: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("2");//run function setText belonging to displayBox and pass string of 2
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "2";//add 2 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button3: {

    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText("3");//run function setText belonging to displayBox and pass string of 3
                 newvalue = FALSE;//the integer is no longer a new value in display box
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "3";//add 3 to existing value in text
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
             }
    break;//Exit the loop
   }
   
   case R.id.button_point: {
    if (newvalue == TRUE)//any new value will be created as new entry
             {
     displayBox.setText(".");
                 newvalue = TRUE; // if button is pressed twice it is now set again               
             }
             else
             {
              text = displayBox.getText();//run function getText belonging to displayBox and set it to text
              text = text + "."; // add decimal to current text value
              displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
                 newvalue = TRUE;//prevent button from being added more than once on screen
             }
    break;//Exit the loop
   }
   
   case R.id.button_cancel: {
    text = "0";// text is set 0
    displayBox.setText(text);//run function getText belonging to displayBox and pass it text object
    runningTotal = 0;//runnninTotal is reset to 0
    previousOp='+';// set previous operator to plus
    newvalue = TRUE;//any new value will be created as new entry
    break;//Exit the loop
   }
   
   case R.id.button_add: {
             //plus button 
             Float rez1;//Float variable called rez1 to hold current result
             rez1 = Float.parseFloat((String) displayBox.getText());//Parse the specified string as a float value and running method getText
             switch (previousOp)// switch loop to deal with operation
             {
                 case '+':
                    runningTotal = runningTotal + rez1;//running total added to result1
                     break;//Exit the loop
                 case '-':
                     runningTotal = runningTotal - rez1;//running total subtracted by result1
                     break;//Exit the loop
                 case '/':
                     runningTotal = runningTotal / rez1;//running total divided by result1
                     break;//Exit the loop
                 case '*':
                     runningTotal = runningTotal * rez1;//running total multiplied by result1
                     break;//Exit the loop
                 case '=':
                     // runningTotal = runningTotal;
                     break;//Exit the loop
             }
             displayBox.setText(Float.toString(runningTotal));//type conversion runningTotal float to string and set to displayBox
             newvalue = TRUE;//any new value will be created as new entry
             previousOp = '+';// set previous operator to plus
    break;//Exit the loop
   }
   
   case R.id.button_sub: {

             //minus button 
             Float rez1;//Float variable called rez1 to hold current result
             rez1 = Float.parseFloat((String) displayBox.getText());//Parse the specified string as a float value and running method getText
             switch (previousOp) // switch loop to deal with operation
             {
                 case '+':
                    runningTotal = runningTotal + rez1;//running total added to result1
                     break;//Exit the loop
                 case '-':
                     runningTotal = runningTotal - rez1;//running total subtracted by result1
                     break;//Exit the loop
                 case '/':
                     runningTotal = runningTotal / rez1;//running total divided by result1
                     break;//Exit the loop
                 case '*':
                     runningTotal = runningTotal * rez1;//running total multiplied by result1
                     break;//Exit the loop
                 case '=':
                     // runningTotal = runningTotal;
                     break;//Exit the loop
             }

             displayBox.setText(Float.toString(runningTotal));//type conversion runningTotal float to string and set to displayBox
             newvalue = TRUE;//any new value will be created as new entry
             previousOp = '-';// set previous operator to minus
    break;//Exit the loop
   }
   
   case R.id.button_mult: {
             //multiply button 
             Float rez1;//Float variable called rez1 to hold current result
             rez1 = Float.parseFloat((String) displayBox.getText());//Parse the specified string as a float value and running method getText
             switch (previousOp)// switch loop to deal with operation
             {
                 case '+':
                    runningTotal = runningTotal + rez1;//running total added to result1
                     break;//Exit the loop
                 case '-':
                     runningTotal = runningTotal - rez1;//running total subtracted by result1
                     break;//Exit the loop
                 case '/':
                     runningTotal = runningTotal / rez1;//running total divided by result1
                     break;//Exit the loop
                 case '*':
                     runningTotal = runningTotal * rez1;//running total multiplied by result1
                     break;//Exit the loop
                 case '=':
                     // runningTotal = runningTotal;
                     break;//Exit the loop
             }

             displayBox.setText(Float.toString(runningTotal));//type conversion runningTotal float to string and set to displayBox
             newvalue = TRUE;//any new value will be created as new entry
             previousOp = '*';// set previous operator to multiply
    break;
   }
   
   case R.id.button_divide: {

             //divide button 
             Float rez1;//Float variable called rez1 to hold current result
             rez1 = Float.parseFloat((String) displayBox.getText());//Parse the specified string as a float value and running method getText
             switch (previousOp)// switch loop to deal with operation
             {
                 case '+':
                    runningTotal = runningTotal + rez1;//running total added to result1
                     break;//Exit the loop
                 case '-':
                     runningTotal = runningTotal - rez1;//running total subtracted by result1
                     break;//Exit the loop
                 case '/':
                     runningTotal = runningTotal / rez1;//running total divided by result1
                     break;//Exit the loop
                 case '*':
                     runningTotal = runningTotal * rez1;//running total multiplied by result1
                     break;//Exit the loop
                 case '=':
                     // runningTotal = runningTotal;
                     break;//Exit the loop
             }
             displayBox.setText(Float.toString(runningTotal));//type conversion runningTotal float to string and set to displayBox
             newvalue = TRUE;//any new value will be created as new entry
             previousOp = '/';// set previous operator to divide
    break;//Exit the loop
   }
  
   case R.id.button_equals: {
             //divide button 
             Float rez1;//Float variable called rez1 to hold current result
             rez1 = Float.parseFloat((String) displayBox.getText());//Parse the specified string as a float value and running method getText
             switch (previousOp)// switch loop to deal with operation
             {
                 case '+':
                    runningTotal = runningTotal + rez1;//running total added to result1
                     break;//Exit the loop
                 case '-':
                     runningTotal = runningTotal - rez1;//running total subtracted by result1
                     break;//Exit the loop
                 case '/':
                     runningTotal = runningTotal / rez1;//running total divided by result1
                     break;//Exit the loop
                 case '*':
                     runningTotal = runningTotal * rez1;//running total multiplied by result1
                     break;//Exit the loop
                 case '=':
                     // runningTotal = runningTotal;
                     break;//Exit the loop
             }
             displayBox.setText(Float.toString(runningTotal));//type conversion runningTotal float to string and set to displayBox
             newvalue = TRUE;//any new value will be created as new entry
             runningTotal = 0;//current total is reset to 0
             previousOp = '+';//set previous operator to plus
    break;//Exit the loop
   }//End of equals method
  }//End of main switch case statement
 }//End of onClick method
 //Abstract method is overridden with menu parameters
 @Override //This means the method is overriding base class method
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;//Return boolean true
 }//End of method onCreateOptionsMenu
}//End of main activity class