Week Five

Happy Friday! Today marks our half way point for this summer. I have learned so much my first five weeks that I am excited to see what the next five will bring.

Last Friday we met with our mentor and adviser and decided that we needed to officially restart our ESM application. The original code was using Google Credentials, and unfortunately this was causing problems when testing the application on some phones. This was because Google Credentials only recognized emails that ended in “@gamil.com”  as a gmail email. So if a phone was not connected to a recognize gmail email, than the application would not work. So we decided to start over. Luckily, we have learned a lot about the functionality of the application and programming in Android studio these past few weeks, so starting over wasn’t as difficult as we had thought. We were able to get SO MUCH done this week that we are finally making some progress. Here is a more in depth description of week:

After our meeting Friday, we had officially decided that we were going to start over and not use the code from the original ESM application. The original application was using Google Credentials to verify the device, and was causing issues with the Microsoft Band. With this in mind, we decided that starting over was our best option. So Monday morning we began working on this new application. Our first big task was setting up the SQLite database. I began on this task by going through the slides Kay had put in a google drive for us. The slides stepped me through each step of setting up the database, and by the afternoon I had a SQLite database in our new application! Then I worked on setting up the PendingSurveys table in the database. This table would include all of the answers from the survey questions and other information pulled from the Microsoft Band. I was able to test the PendingSurvey table by inserting new surveys from a test XML file I had made. I was so excited about everything finally working and didn’t stop working until nine. All in all, it was a good day.

Tuesday I accomplished so much! Things were finally starting to work. I began the day by setting up the Settings page. The user would input the start and end of their day into this page. This would help us to determine when to notify the user to take a survey. I created two Edit Text widgets on the XML files for the user to input this data. Once they were submitted this information was directly interested into the SQLite database. As of now each time this information is submitted it is a new row in the database. This is so the researchers can see when the participants changes their settings information. Once the settings page was complete, I was able to begin setting up the alarm system.

The alarm system would include three kinds of alarms. These alarms are:

  • an alarm to check heart rate
  • an alarm to notify the use to take a survey
  • an alarm to sync the SQLite and MySQL databases

I began by setting up each alarm in an AlarmReceiver class. The AlarmReciever class would set up the alarms and then determine what should be done based on the alarm ID. The alarms were set up using the android AlarmManger class. The alarm for heart rate and syncing data were relatively easy to set up, but I had to create an algorithm for picking the survey alarms. This algorithm would create six alarms that would go off based on which part of the day. The day would would be split up into three sections and two alarms would go off for each section. This was all done with a little math and query on the Settings table. This algorithm still needs some work, but this can be done once more of the application is written.

I then ended the day by doing some research on how to sync an SQLite database with a MySQL database. Luckily, I have some experience working with a MySQL database so hopefully this task won’t be too difficult. Nonetheless, I am definitely making lots of progress on the application.

Wednesday was a busy day. Aislinn and I had a meeting with Majdah, the ProHealth seminar, and a lots we wanted to get done. We started the day by discussing our new application. After Tuesday, I knew that we needed to plan for So Aislinn and I created flow diagrams of the functionality of the application. This took some thought, but hopefully this will make the programming easier. Here are the diagrams we created:

Database Sync

Figure 1: Database Syncing Alarm

Heart Rate Alarm

Figure 2: Heart Rate Alarm

Pending Survey Activity

Figure 3: Pending Survey

After we created the diagrams, we had a meeting with Majdah. During the meeting we asked lots of questions about the functionality of the application. After having a better understanding of the functionally of our application, we began coding.

Aislinn and I spent the rest of the day working on the heart rate alarm. This general functionality of this part of the application is shown in Figure 2. I had already starting working on this part of the application Tuesday, so I briefly explained what I had done and began working with Aislinn. She began working on the XML files and I worked on the passing surveys through java pages and the database. It worked out well, and by the end of the day we had things working!

Thursday Aislinn and I needed to finish our ProHealth deliverables. We spent the morning peer reviewing and working on our paper. Once this was finished we had a few things we needed to get done with our ESM application. First, we needed to make sure that the sure could take a pending survey from the pending survey page and updated it in the SQLite database. To do this we needed to pass data through each Question XML page. Then once the survey has been passed through each page we needed to update it in the database. We wrote an updateSurvey() method to do this. The method would update the line of the database where the survey ID numbers matched. Once this was complete our next step was to sync the SQLite database with the MySQL. We had already done some research on this, but it may be a bit trickier than we had originally thought. We need to write an PHP script that will update the MySQL database with the SQLite database information. We are hoping to finish this relatively soon.

All in all, it was a very good week! We were able to accomplish lots of things that needed to be done this week. I feel like Aislinn and I are finally starting to really understand how to program an Android application. Although we have much to learn, we are both enjoying our time in the office working.

Here are a few other things we did this week:
Professional Website
Reviewer Response Table