How Incredible Is Your Incredible: Part Two of the SS Sundog Journey

Having already built a number of Android applications, the process was familiar to me. But I did need to research using the GPS, camera, sending SMS messages, and creating a background service to run everything. The biggest obstacles were determining the best way to create and handle the loops that had to occur and getting the camera to work inside a service.

I started with the easy tasks; getting the SQLite database built, creating the UI and working on receiving GPS data. After this, I worked on the sending SMS portion of the app, which would send a link to Google Maps with the current location of the phone, distance traveled, current speed, elevation, and timestamp. I was able to coordinate this by putting the time logic inside the GPS listener. Each time the GPS of the phone would get an update on its position, the code checks to see if it has been at least the specified SMS time interval and if it was it would send the SMS.

After I got the SMS messaging working, I moved onto the camera. After extensive research, I discovered that taking pictures inside a service is not possible. In order to take a picture within Android, a valid surface view containing a preview image currently displayed by the UI has to be present. This was my biggest frustration with the whole project.  It didn’t make sense to me that a piece of hardware couldn’t be used unless an unrelated piece of software was in place.  It was like saying your phone cannot make phone calls unless there is a picture of a phone displayed on your screen.

Since running the app in a service wasn’t going to work, I decided to just run it as a standard app. This meant I had to make a few UI adjustments. In order to keep taking pictures, I had to override the time-out feature on the screen. I also altered the brightness of the screen to conserve battery life. Another camera challenge came when I tried to have the pictures taken within a timed loop. After some testing, I discovered that I could spin off a new thread just for taking pictures. This thread would take a picture, pause for the specified interval amount, and take another picture. This cycle repeats until the logging is stopped by the user.

In addition to the camera customizations, I added a few more features. I made it possible to export all the flight data in KML format so I could load the KML file in Google Earth to see the actual flight path of the payload. I also used the Google Maps API within Android to draw out the path on the phone. This made it easy to see the path without having to load it into Google Earth.

The application took me a couple of weeks to develop in my free time, most of which was spent testing and retesting because I wanted to make sure there was little that could go wrong on the day of the launch. I also made the app as simple as I could to lower the probability of errors occurring. 

As a test before the launch, I took my phone with me while running the Fargo-Moorhead Mini Marathon and sent my wife a text message of my location every ten minutes. It worked great and I found a bonus use for my app! I could give people location updates periodically, and since it runs as a service, it doesn’t affect any other functions of the phone.

Read Part One Here

Comments

Be the first to comment!

Leave A Comment

Please help us stop spam by typing the word you see in the image below: