CS 185C/286 - Lecture 1

Cover page image

Cay S. Horstmann

Lecture 1 Quiz 1

Put your answer into Piazza.

Which of the following is true according to Programming Android Chapter 1?

  1. You should use OpenJDK, not the Oracle JDK, for Android programming.
  2. You should install Eclipse in your home directory, not in /opt.
  3. The ADT can be installed into Eclipse, NetBeans, or IDEA.
  4. To run your app on your phone, you must first become a registered developer.

Android Components

Android History

Android and Java

Android App Components

Android Development Toolkit (ADT)

git Basics

Git workflow

Lab

Checking out Your Repo

  1. Each of you gets a personal private repo (shared only with your professor). That's what you should use for checking in lab work and homework. The coder submits the code, the scribe submits a file report.txt
  2. In your home directory, run
    git clone git@github.com:sjsu-fall2013-cs175/firstnamelastname.git cs175
    where firstnamelastname is your first and last name (from your SJSU records), such as jonathansmith. What happens?

    If you got a warning, that's ok. But if you got an error, that needs to be fixed before you can go on.

  3. Run
    ls -a cs175
    What do you get?

Getting Started with Android Programming

  1. Run ~/adt-bundle-linux-x86-*/eclipse/eclipse
  2. Select File -> New Android Application
  3. App and project name Lab01, package name edu.sjsu.cs175.lab01, everything else default. Click Next.
  4. Pay close attention to uncheck Create Project in Workspace. That's an evil and stupid option. Instead, change the location to /home/username/cs175/lab01, where /home/username is your home directory such as /home/jon. (Unfortunately, Eclipse doesn't understand ~)
  5. Next, next, next...finish
  6. Close welcome screen to see your project
  7. src is the Java source, res are the UI resources
  8. What source files were generated by the wizard?
  9. Where does the "Hello, World" message come from?
  10. Where is the class R defined?

Running Your Program

  1. Run your program by clicking on the green Run button or selecting Run from the Project menu. What happens?
  2. Click Next.
  3. Select Launch a new Android Device. What happens?
  4. Click on the Manager button, then on New
  5. Set the AVD name to nexuss and choose Nexus S for the device
  6. Click Ok, close the device manager. Click Refresh
  7. Run the program again. What happens?

Changing the Message

We want to change the message to Hello, Dave.

  1. Does the application source file contain the string "Hello, World"?
  2. Click on activity_main.xml in the Package Explorer and then on the activity_main.xml tab next to the Graphical Layout tab. What do you see?
  3. What happens if you change @string/hello_world to @string/hello_dave?
  4. Ok, that couldn't have worked. Look inside values/strings.xml. What do you see?
  5. How do you change the message? Be sure to run the app.
  6. Why do you think that the message wasn't stored directly in the activity_main.xml file?

An image

We want to add an image. Here's one of Dave.

  1. Move the image to the ~/cs175/lab01/res/drawable-hdpi directory.
  2. Go to activity_main.xml and click on the Graphical Layout tab. Select Images & Media and drag an ImageView on the screen. What happens when you drop it?
  3. Hook up the 2001_dave.jpg file.
  4. Try running the app. What happens?
  5. Look in the Problems tab. What's the problem?
  6. Double-click on the error message. What's really the problem?
  7. Why shouldn't you fix it by editing R.java?
  8. How can you fix the problem?
  9. Now run the program. What happens?

Checking in a Project

  1. Run find cs175. What do you get?
  2. Give an example of an automatically generated file that should not be checked into version control.
  3. To make sure that you don't check in inappropriate files, place a file named .gitignore into the ~/cs175 directory. Note the dot in .gitignore. The file should contain the following:
    .classpath
    .project
    .settings/
    bin/
    gen/
    local/          
    local.properties
    release/
    *~
    Now run git add lab01 and git status -s in the ~/cs175 directory. What happens?

    You should see a listing of files that haven't yet been submitted to version control. None of them should be class files, metadata files, or generated files. Check with me if this looks wrong.

  4. Run
    git commit -a -m "Done with lab 01"
    git push
    What happens?
  5. To see that you did it right, change to /tmp and clone your repo again. How did you do that?
  6. What files did you get?
  7. All this checking in was done by the driver. Now it's the scribe’s turn.
  8. In your home directory, run
    git clone git@github.com:sjsu-fall2013-cs175/firstnamelastname.git cs175
    where firstnamelastname is your first and last name (from your SJSU records), such as jonathansmith. Then run
    mkdir cs175/lab01
    Place your report.txt into that directory. Run
    cd cs1
    git commit -a -m "Done with lab 01"
    git push

Reading Before Next Class