Please note that this writeup is more in-depth than the video. The video with its limited time did not allow me to display all the features of my application.
This first screenshot displays our main list of all the recent earthquakes. We compiled this list by calling on earthquake.usgs.gov. This url combined with a date format allowed us to pull the earthquakes for a particular day (set to today) in a parseable format. This endpoint has information about each earthquake, but we pulled its coordinates, magnitude, location, and time. This information is then displayed in an easy to digest list format. Once we have the information about each earthquake, we actually pulled it into a HashMap with keys as the list position and an ArrayList with all the relevant information as the value. With this HashMap we then generate the list with a ListAdapter.
This next screenshot shows an example of a Map location of an earthquake. We can get to this screen from the Earthquake list by clicking any list item. A click will then display the map of where the earthquake was along with relevant information about the earthquake. The map is generated from a GoogleAPI client then displayed on a page using a MapFragment. From clicking a specific earthquake list item, we send over relevant information which we need to display the map. We use an Intent to send over the coordinates along with the magnitude and location of the earthquake. With this information, we can animate the Map to the location of the earthquake with a marker already in the exact location.
Then above the map, we also have some relevant information about the earthquake, including its location, magnitude, and distance. Distance is actually calculated using the coordinates of the earthquake and our current location. Our current location is another LocationAPI which is able to give us our current coordinates. We can set these coordinates to anywhere in the world from the emulator. Then using a distance calculation, we are able to display the actual distance we are from the earthquake epicenter. If the GPS on the phone is not turned on, the default location is set to my hometown in Singapore.
Next we have the watch notification which displays alongside the Earthquake Map. The notification is sent when an Earthquake is clicked on from the List of Earthquakes or a new earthquake happens. This notification is handled from one of two locations: the Map class and the MainActivity class. The Map class activates it when the map itself loads and the MainActivity class activates it when the list updates with a new earthquake. As you can see, the notification also has some relevant information about the earthquake which is also displayed on the phone.
We have also added a Dismiss action for the notification which allows the user to tap on it and dismiss the notification. This dismiss is actually setup as a notification action which calls a PendingIntent which is directed to a BroadcastReceiver. This BroadcastReceiver is a new class which simply kills the notification itself.
Another action which we have is the "Open on phone". I have done it such that when this is clicked, we go back to the Earthquake List.
When the watch is shaken and we have selected an earthquake to view, the phone will display a photo from the location of the earthquake. The photo itself is pulled from Flickr in another class. We call the FlickrAPI to find these photos and buffer read them. The photos get converted to a Bitmap and then placed into the XML through an ImageView.
The shake from the watch which activates an image is actually quite a complicated process. For us to first register the shake, we setup a service to run in the background of our wear device once the app is started on wear. This service constantly runs in the background listening for a shake from the device. We then can test the shake using telnet and connecting to the wear device. Once the shake is registered by the Service, it connects to a GoogleAPIClient to send a MessageAPI to the mobile device. The mobile device here also has a GoogleAPIClient connection where it is listening for a message. Once it gets the signal it then sends an Intent to the FlickrActivity class to get the photo and render it on the device.
Comments