Android

 
  • Locate the path to the keystore
    • In Eclipse, navigate to Window | Preferences | Android | Build
    • Under "Default debug keystore" you will find the path to the keystore
  • Open a command prompt
  • cd C:\Program Files\Java\jre6\bin (or wherever your java installation is)
  • Run the command: keytool -list -alias androiddebugkey -keystore (path to keystore)\debug.keystore -storepass android -keypass android
  • It should return something like:
    androiddebugkey, Sep 2, 2010, PrivateKeyEntry,
    Certificate fingerprint (MD5): XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
  • Go to http://code.google.com/android/maps-api-signup.html and paste your certificate fingerprint and check the box to accept the terms (if you accept them of course)
  • If all goes well, it will take you go a page that says: Thank you for signing up for an Android Maps API key! Your key is: (your key)
See also:
Tags: 

For work I have to do a small presentation on programming for the Android phone.  (See: http://armyso.blogspot.com/search/label/Android)

Well today, I wanted to make sure all my files were in C:\Users\Public because when I do the presentation I want to do it under a separate user on my computer just so that my coworkers don't see anything personal on my computer. I'm always weary of mixing work and personal stuff so this is to make me feel better about it. Anyway Eclipse doesn't like you just moving stuff, but I did anyway. In my Package Explorer all packages were messed up because I had moved the locations.

To fix:

  1. Right click inside Package Explorer and click "Refresh". It will then say something about not finding the files or whatever, so just delete it (don't check the option for deleting from the hard drive). If you don't see the Refresh option that means that you have a Package selected. To unselect the Package press Ctrl + click.
  2. To import your existing Projects, go to File | Import | General | Existing Projects into Workspace | Next
  3. Select the directory where your new Workspace is and click Browse and press Okay
  4. It will find all the projects in that directory, if it already exists in your Workspace you wont be able to import it (duh!)
  5. Click 'copy projects into workspace' and click Finish
Before I did this, I had to change where it was pointing my Workspace, which isn't as straightforward as it should be.
  1. Go to C:\eclipse\configuration\.settings (or wherever your program file for Eclipse is)
  2. Edit the file org.eclipse.ui.ide: RECENT_WORKSPACES
To move the actual files, I just moved them within Windows Explorer

This will be a stream of consciousness post as I am going through this book....

Emulator/Testing the App

Wow testing my Android app on my phone is extremely easy... I plug in the phone, select usb debugging and it'll automatically run on the phone.

When you first open the emulator, it takes forever to load... This would be a good time to put my laundry away lol. Okay it should only really take 2 or 3 minutes to load, so something was wrong with my project, so I just deleted it and started over (I hadn't coded anything for it yet anyway). Then the emulator loaded within a couple minutes. It took about 5 minutes for it to load up all the way and to show the app, so if yours is taking way longer than that, there's something else wrong. I think the problem was I hadn't closed my first project "HelloAndroid" before running this, so I think it got confused. I'm new at this so I could be wrong and this is my first time using Eclipse.

To make the emulator rotate, like when you rotate your phone, press Ctrl+F11. It'll rotate the entire thing to begin with, and it'll take few seconds to look right.

screenflip
screenflip

wait a few seconds...

Colors

I saw this code in the book:

#3500ffff

I was confused because I had never seen a value like that before. With web development, I'm used to seeing #RRGGBB. Why was there an extra 2 digits? Turns out that is to specify Alpha (I'm not sure what that is exactly, you can view the wikipedia article on it, but I think it has something to do with transparency). AARRGGBB

http://developer.android.com/guide/topics/resources/color-list-resource.html

Syntax

"The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource" http://developer.android.com/guide/topics/ui/declaring-layout.html#id

Error Messages

I gotta say, I love the error messages so far. Most of learning something like this takes place when you have to debug. The error messages are very descriptive and tell you what is wrong.

Example:

   android:id="@id/new_button"

   android:text="@string/new_game_label" 

Error: No resource found that matches the given name (at 'id' with value '@id/new_button').

Fix: I forgot to include the + symbol which defines a new resource.

Tags: 

I actually opened my Android book and skimmed through some pages (stuff I have already done to set it up) and I opened up the IDE (Eclipse) but have not actually done anything. Getting started is typically the hardest part and I've done that by opening the book and opening the IDE. Tomorrow I plan on actually getting a good part of it read. Getting through these two books is one of my deployment goals. The first book I am using is "Hello, Android" by Ed Burnette. By the end of this book, I should have an understanding of how to do a lot of things with the Android. I can't wait until I get to the database part because I LOVE databases.

If you are looking for a way to get started, google has free resources. I found it a little hard to follow. It seemed that on one page it told you that you needed to do this first, but on the other page, it told you that you had to do that before you could do this. I eventually figured it all out. I have my first "Hello, Android" app done.

Typically, the first "Hello, World" is the hardest part of learning a new language. Not that Android is a new language, but it follows the same learning process. Android uses java, which I had to learn for my core IT classes at RIT.

Anyway, tomorrow is Friday and I'm allowed to stay up late (I give myself permission since I don't have to wake up early the next day). I typically program better at night, especially around midnight, but most days I can't stay up that late.

Tags: