The personal wiki of ...

Getting Started: Running Hello World

Instead of making you type in the programs, we are going to use a technology called QR codes.

QR codes are two dimensional versions of barcodes like are used in supermarkets at the checkout.

Like barcodes, the black and white colours represent "on" and "off" or "1" and "0". A barcode can encode a small set of numbers like a product ID.

QR codes can hold many more numbers and the numbers correspond to characters. You can put about 4,000 characters in a QR code.

We are going use QR codes as any easy way to load programs onto the phones.

1. Find the SL4A program (used to run our Python programs)

nexus one home.jpg

2. Start the SL4A program

Find the SL4A program, this should look like this:

logo.png

Start the program by tapping it.

You should see a list of programs (scripts). For example:

list-of-scripts.png

3. Bring up the barcode reader

Press the Android phone Menu button (shown in red below).

nexus one menu.jpg

Press the Add button.

scanbarcode.jpg

Choose Scan Barcode.

android-scanbarcode-menu.jpg

This brings up the scanner. Line the red line up over the QR code.

android-scanning.jpg

Try it now with this QR code. This is for a script called HelloWorld.py.

chart-1.png

4. Running the program.

Find the cyber-helloworld.py in the list of scripts and tap the name. This will bring up a menu.

script-selection.png

Start the script by choosing the Run (with Terminal) option (highlighted in red below) -- the wheel runs it without the Terminal and the pencil allows you to edit the script directly on the phone.

sl4a quickaction.png

This will bring up a Terminal on the phone where you can see the result of running the program (use the volume controls on the left side of the phone to enlarge the size of the output).

You should see something like the following after the program runs, finishes (process terminates) and an exit dialog is displayed.

cyber-helloworld-output.png

Choose YES to close the program (the data won't be lost because it is being stored on the phone's SDCARD).

5. Changing the program

Let's change the program.

This is the program:

cyber-myhello.py
print('Hello')
print('Android')
print('from')
print('MY NAME')

The first line is the name of the program cyber-myhello.py and the remaining lines are the program.

print('Hello') displays everything between the quotes ('Hello') get displayed on the screen.

What you are going to do is change MY NAME to your name.

We are going to use a QR creator to do this.

Open a new Browser window and this address in a new window.

http://zxing.appspot.com/generator/

Click on contents and choose Text

Copy and paste the program code into the Text content box.

Change your program so you display your name.

Create a QR code by click on Generate->.

Now try and run the program. Check it with a tutor smile

6. Next: Making your phone talk

Normally we talk to the our phone. The next activity is making your phone talk to you.

CB13-TalkingPhone
I Attachment Action Size Date WhoSorted ascending Comment
android-scanbarcode-menu.jpgjpg android-scanbarcode-menu.jpg manage 88 K 24 Jan 2013 - 20:42 Main.ian  
android-scanning.jpgjpg android-scanning.jpg manage 92 K 24 Jan 2013 - 20:42 Main.ian  
chart-1.pngpng chart-1.png manage 1 K 24 Jan 2013 - 21:03 Main.ian  
cyber-helloworld-output.pngpng cyber-helloworld-output.png manage 42 K 20 Jan 2012 - 01:02 Main.ian  
hello-world-py.pngpng hello-world-py.png manage 1 K 19 Jan 2012 - 23:35 Main.ian  
list-of-scripts.pngpng list-of-scripts.png manage 78 K 20 Jan 2012 - 00:59 Main.ian  
logo.pngpng logo.png manage 2 K 24 Jan 2013 - 20:08 Main.ian  
nexus_one_home.jpgjpg nexus_one_home.jpg manage 45 K 24 Jan 2013 - 20:08 Main.ian  
nexus_one_menu.jpgjpg nexus_one_menu.jpg manage 46 K 24 Jan 2013 - 20:08 Main.ian  
scanbarcode.jpgjpg scanbarcode.jpg manage 81 K 24 Jan 2013 - 20:41 Main.ian  
script-selection.pngpng script-selection.png manage 79 K 20 Jan 2012 - 01:02 Main.ian  
sl4a_quickaction.pngpng sl4a_quickaction.png manage 16 K 20 Jan 2012 - 00:49 Main.ian  
terminal.pngpng terminal.png manage 1 K 19 Jan 2012 - 23:43 Main.ian  
Contact Us | Section Map | Disclaimer | RSS feed RSS FeedBack to top ^

Valid XHTML and CSS | Built on Foswiki

Page Updated: 24 Jan 2013 by ian. © Victoria University of Wellington, New Zealand, unless otherwise stated