It is the Sunday after Capstone presentations, and I’m fixing up my code for my defense, which I have on Tuesday. Overall, my presentation went reasonably well. I believe I rushed through defining how Oauth 2.0 works and how I implemented it. During my presentation and the days leading up to it my mobile application would be working half the time. The other half it would fail. At the time I thought I had a memory leak, but after further investigation I don not believe that is correct.
In my service, which runs the bulk of my code, I call an Async task to pull the string from my JSON files, so that I can parse it into an Array and use it in my app. Using logs, I was able to determine that my app calls the Async task every time and opens a good connection. However, when I get the input stream of the connection half the time it returns 0, meaning that there are no bytes in the file. This is untrue, my JSON file does have something in it. From my research I could not find a definite answer to fix this. One answer was given that said it was the server’s fault? I want to talk with Dr. McVey and Dr. Pankratz to determine how to fix this. Instead I created more columns in my database that saves the heartrate, sleep, and activity data. This way I have an http call to one of my php scripts that grabs the data from the database. That data is returned as a string and then parsed, to get the heartrates. Since the presentation, I have been copying and pasting my code into a new project and changing some of the naming. My big change that I took out, was the broadcast receiver. The broadcast receiver was erroring out when the app was not in the foreground or in the recently used apps section. I know just have one of my Activity’s using the systemclock to call the service every five minutes. The Broadcast receiver as more accurate but this new method does not giving my the same errors the broadcast receiver did when the app is closed.
0 Comments
We're about two weeks out from presentations. The stress is mounting, not just with capstone, but with my other classess. My main progress has been trying to figure out how to run an Http request from android studio. I would llike android studio to contact the compsci02 server to run a PHP script. For testing purposes I created a seperate project that had two buttons. One button accessed Fitbit using Google Chrome. It is how I am getting my data from Fitbit, and how I have run previous versions of my app. It is also the way that Tom ran his last year. My second button is an Http Request that runs in the background. My initial runs showed nothing happening when the Http button was clicked. After talking with McVey we devised a test. I created a simple PHP script that accessed a file grabbed the contents, (which was a number), increased the number and wrote it to the file. My PHP script worked when ran in a browser, but the code I had that called the Http Request in android studio did not work. After some more research I found a simpler version that calls a Http Request. It does not use a buffer and when executed it worked correctly. I am meeting with McVey tomorrow to see if we can create a PHP file that will use the token that is given to the user by Fitbit to access it using an Http Request.
I have also been working on setting up my Music Player and breathing exercises in my app. I have five breathing excercises that were created by a certified yoga instructor. Sof ar they range from 1 minute to 5 minutes. My music player uses and Adapter and Listview similiar to what we using in CSCI 350 Program 3. When the song is clicked it will play. The only issue I am having with that is getting the song, with out hardcoding it when I create the mediaplayer. I also have thought of just putting the R.raw files in an array and grabbing them by posititon. However, I feel that could be very messy. I have tried multiple ways to try to pull the r.raw files using the Uri.parse method, but so far I have not had any luck. That's all for now. Till next time. -Renae Since my last blog post:
I have implemented a service and a broadcast reciever. This allows Fitbit to be called repeatedelly while the app is not up. It will help retain battery power because it runs in the background on defined intervals of the alarm. Everytime the broadcast receiver is called the background service is executed, and calls Fitbit. The service starts to run in the onStartCommand method, and all the heavy lifting of calling Fitbit is done in this thread. Once the thread is complete, the service will be stoppend util the broadcast receiver calls the service again. The issue that I am having with this, is my timer isn't always exact. I am using a built in timer function that allowus you to set a repeating alarm. I'm hoping that once I have the full app up or mostly running that I can go back and take a closer look at the alarm and see if there is an easier way to do this. It also calls googlechrome everytime it grabs data from Fitbit. This causes alot of open tabs, and isn't the friendliest for users. I reached out to Thomas, to see if he experienced this as welll. I also accomplished creating activities that allows the user to logon to the app that uses a table that is on my METKE322 database that I had created last semester. I was able to find some code that uses php files. They are located in my folder on compsci02. There is one java file that I need to understand better. It looks like it is the file that connects the php to the android studio. I plan on stepping through it more closely. My next steps are to do some tests with notifying the user if the heartrate is at a certain number. I also need to figure out how to know which Fitbit account is connect to the apps login username. After countless issues trying to update my Fitbit on the Fitbit app I was able to. For some reason the second Charge HR (the black one) would not update on my Laptop or my phone. When I logged into my Fitbit account on my mother's phone it updated immediately. I logged backed in to my account on my computer and it was up to date.
I am now wondering if my original Fitbit Charge HR (the purple one) was not the issue on the update, but rather my computer. I have yet to send in the replacement order. Instead I am going to try to connect it using my mother's phone. If it works, I will be reaching out to Dr. Pankratz if he still wants me to order a replacement. I have taken code from Thomas's website that shows the Fitibt data. I will be testing it tomrrow after my Fitbit collects a day's worth of data. Following that I will start working on my algorithm to determine stress. So far I thinking that I will be comparing current heartrate to resting heartrate. If your current heartrate is 20 beats higher than your resting heartrate I will look at steps. If your steps have not incremented in the last five minutes I will presume you are not working out and potentially are stressed. That's all for now. -Renae Early this week I tried to implement the heartrate data by changing my settings on the Fitbit dev website. When I tried to connect to Fitbit with my app, it failed. I was reable to establish my prior connection, but I still did not did have any output for my heartrate json file. The following day, I did the same steps and my app was able to connect to Fitibit. When I checked my heartrate json file a line of code had been outputted to it.
My struggle right now is finding examples, or help to get my data from the json files into the app. I want to be able to populate graphs of heartrate and sleep and compare them to Fitbit's, to make sure that the data is correct and I'm parsing the correct things. I would love to be able to show graphs and have my algorith created by the beginning of March. Then I can start working on the enhancements, breathing excercises, music, ect. -Renae This week when I was creating my Gantt and Pert graphs I got the feeling that I was far behind comapred to where Tom was last year. It pushed me to reach out to Pankratz to get the Fitbit so I could start trying to get the data into my app.
Following Tyler's and Tom's documentation I was able to create an account for the Fitbit and get the authorization I needed to get my data. I need to check to see if I have access to heart beat. In Tom's documentation he said that you need to contact the devlopers at Fitbit to get access to heartrate. He's probably right, because when I tried to add the code that grabs the heartrate data it crashed my app. For a while nothing was being outputted to my json files. I realized that the permissions were incorrect and had to changed them. Now that they have been changed the data is being grabbed. My plans for the week are to do some more researching on json files, just because I am not used to them all that much. I also need to start thinking about how to implement the auoth (what's redirecting me to Fitbit and grabbing the data). Thats all for now. -Renae On Wednesday, I met with Health and Wellness to talk over creating the app. Carol, the nurse I met with was very interested in the app, and asked to be invited to my presentation in April. She seemed to think this app was only geared to students, and suggested I put contact numbers such as Health and Wellness' in the app. She also gave me a self assesment survey based on a few questions, you can determine how stressed you are that day. I started implementing this survey into my app, by creating an Activity that showed a fragment with the question, and radio buttons showing the answers. If a user's score is high I plan to notify them more to take a break, since they seem to have a higher stress level. That's all I have for now. My plans are to meet with Dr. McVey and Dr. Pankratz to get the FitBit so I can start working on getting the data from it.
-Renae We were assigned our senior capstones last week. The idea about getting my capstone had been plaguing my dreams the night before. I wanted to get something challenging, in the hopes that it would be because the professors had confidence in my abilities.
After reading the initial email from Dr. Pankratz I was really happy with the outcome. I was given the capstone Sensing Stress, where I have to create an app that can sense stress triggers based on Fitbit data gathered. Even though creating an app isn’t my strongest skill, I personally connect with the stress aspect. Like most college students I have experienced stress and anxiety. So far I have accomplished downloading stress relieving apps to get some ideas. I have also meet with the Counseling Services on campus to talk about what they recommend to do to help relieve stress. On Wednesday I am meeting with Health and Wellness to go over some of the same questions. By Thursday, I would like to have feedback from my peers based on a survey I will be creating about stress and what students would like in an app. Even with out student opinion I would like to implement the following in my app:
-Renae |
|