-
Notifications
You must be signed in to change notification settings - Fork 0
Mobile ICP 4
The purpose of this ICP was to learn how to access different components of the Android system, such as the camera, location services, and various sensors. We were tasked with creating 4 activities, all incorporating a different component.
Activities
- Maps Activity - Location services and Google Maps
- Camera Activity - Camera
- Audio Recording Activity - Audio recording and playback
- Storage Activity - Internal storage
The hardest part of this ICP was handling permissions. In order to access the components discussed above, you must first check to make sure your activity has the permissions to do so. If it does, you can continue, if it doesn't, you have to ask the user to provide them. Once the permissions were handled, everything else was as simple as reading the API docs for the required methods.
At first, this seemed like one of the harder ICPs we've had thus far. Whenever you have to fill in existing code, it makes it a little harder. First you have to figure out what the code is doing, then you have to figure out how to integrate your solution into it. It's especially challenging when you don't have a firm understanding of what's going on. For instance, it took me a while to figure out that I needed to call the request permissions method and provide a callback for it, and where to put them. On top of that, on some of the activities, it wasn't exactly clear what code had already been provided and where we were supposed to start. So it took several hours of combing through Google's docs and studying the ICP code to figure out what was going.
Initially, this ICP was frustrating. It became much easier once I figured out how everything fit together, and I ended up enjoying it. The initial difficulty forced me to research permissions and Android components, which in turn, led to a greater understanding of them and how they work.
Location Activity
Location services permission request callback function
Checking for Location permissions and requesting them if they haven't yet been given
Camera Activity
Taking a picture
Displaying the saved result
Checking for permissions, requesting them if they haven't yet been given, and starting the camera intent once they've been provided
Audio Recording Activity
Accessing the media recorder and saving the recording
Storage Activity
Displaying the saved text
Using an output stream to save the text input
Using an input stream to access and display the previously saved file