Thursday, October 18, 2012

Coding for Android

For the past 2 weeks, I have been going through some of the coding process for Android.  But before I could starting coding, I had to first figure out what I deem necessary to be part of the basic functionality of the app.

Since the app would need to save information, the user should be able to enter text via a text field and press a button when done -- much like in sending an email.  Furthermore, the information would need to be stored somewhere -- maybe in a database.  As a secondary need, the app should be allowed to generate different pages or views.

I went through a bunch of tutorials to understand the functionality on the following:
  • How to set up a built-in  Android emulator for my laptop
  • How an on-screen button press sends command
  • How to allow a user be able to input text on the screen
  • How multiple pages (or views) can be generated for the app
  • How to store the input text to a database for retrieval

A built-in emulator for my laptop is needed for testing.  This saves me time from having to upload my code to my android phone; it also prevents me from inflicting any catastrophe to my phone in case my code malfunctions severely.  The Android emulator is like a pseudo-phone where you have basic phone interface such as the display and buttons.  However, you can't make phone calls to/from it.  A screenshot is shown below.

Android Emulator Screenshot



The next 2 tasks -- functionality of button presses and text fields --  are pretty straight-forward. Defining buttons and text fields are pretty explicit in coding.  Buttons and text fields need to be defined in the XML file.  Furthermore, their properties need to be assigned.  The next 2 images show a sample screenshot of my simple experiment and a snippet of the code behind it.

Text fields and Buttons
Code Snapshot


The next two functionality are the trickier ones to implement.  In order to be able to generate multiple views (or pages), one view has to be on the foreground and the rest on the background.  This requires a coordination on the command.  I'm still currently in the middle of going through this task.  I'll be posting my findings in the next week or two and maybe along with my database findings.



-----------------------
“If it is now believed that my fellow men may sacrifice me in any manner they please for the sake of whatever they deem to be their own good, if they believe that they may seize my property simply because they need it—well, so does any burglar.”