Friday, February 29, 2008

ICA-CP Info: Getting Midway to work

This is from the Motorola Developer's web site. For those of us who can't download to the cell phone in Midway, this may be the answer. The UID tool is on your CD in the folder, Motorola UID Extraction Tool. Run the Setup.exe file in the folder. But first, install a new version of the USB Driver for the Razr. So, here are the steps:
1) Go to the R drive. In the Motorola Razr USB folder, copy the Handset USB Driver to your computer, then double click it to run the install program.
2) Then, go to the Motorola UID Extraction Tool folder and run Setup.exe.


--------


Problem Downloading Midlets Via The Midway Tool Question


I am having problems downloading my midlet via the Midway tool.
Windows correctly detected the device and I have installed the USB Driver. (Motorola USB Modem shows up in the Device Manager under Modems)

I launched the MIDWay, opened a jad and tried to send it.
It returned,

Opening JAD file.............[OK]
Connecting the phone.........[TIMER EXPIRED]

Downloading canceled.

In fact, I couldn't find the Java App Loader menu item (Click Menu->Settings->Java Settings->Java App Loader.) in the device menu. There were only 'Java System' and 'Delete All Apps' menus.

What did I do wrong?

Answer

The Java App Loader on your phone was not enabled.
To enable it you can use the UID tool that is available for download on the MotoDev website. It is under the "Other Tools" link ie.

For Mobile -> Tools -> Other Tools

ICA-CP: 2/29/08 - Happy Leap Year Day!

On the occasion of leap year day, and since it's Friday, our quiz today will be half as big as announced previously. It will be only 100 instead of 200 points. Our quiz is at this link:

http://www.quia.com/quiz/1322876.html



After the quiz, please continue working on the Razr cell phone assignments.

Thursday, February 28, 2008

ICA-CP Info: SEXI Datatypes in Java

Java Datatypes

State:
There are two broad categories of datatypes in Java, primitive data types which are "built-in" and abstract datatypes, like String and KeyboardReader, which require a library to be imported in order to use them. There are seven basic primitive data types. They are bit, nybble, byte, char, boolean, int, and double.

Size matters with primitive datatypes. It matters because hardware memory is reserved for use by a variable when it is declared based on the datatype. The following are the sizes of the primitive datatypes:
1) bit - may be a 1 or a 0 (zero)
2) nybble - 4 bits
3) byte - 8 bits
4) char- 2 bytes or 16 bits; may be character values
5) int - 4 bytes or 32 bits; may be integer values
6) double - twice the size of an int at 8 bytes or 64 bits
7) boolean - 1 which is True or 0 (zero) which is False

Of the other datatypes that we have used, the datatype String is multiple "char" types or multiple characters in size.

The size of a variable's datatype determines what kind of value a variable can represent. A variable of datatype bit can only be a 1 or zero. If I declared this variable:

bit myBit;

I could never assign it the value of 3 or 6 or 999. The largest number that myBit can represent is just one. It is similar for an int declaration of:

int numberOfStarsInTheGalaxy;

Could I represent a googol with numberOfStarsInTheGalaxy? Well . . . since a googol is a 1 followed by 100 zeroes or this number:

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

and since the largest number an int can represent is 2147483647, I think the answer is a definitely "negatory!" Could a googol fit in a double datatype (hint: a double is 64 bits big)?

Elaborate:
The size of the datatype determines how high one may count or how many characters one may have. For example, since a bit is 1 or zero, the highest one may count is 1. With an int datatype, 1 bit is used for the positive or negative integer sign leaving 31 bits for representing the integer number. If every one of the 31 bits for counting is a one, we would have 31 ones: 1111111111111111111111111111111 (I think that's 31). If we put those 31 ones into a scientific calculator in the binary counting system, then change the counting system in the calculator to decimal, we find that 31 ones in binary equal 2,147,483,647. So, that's the largest positive number we can represent with an int datatype. The largest negative number for an int is -2,147,483,648. For the double datatype, one bit is used for the sign and the remain 63 (out of 64 bits) is used to represent the number value. For the char datatype, the largest amount of data that can be represented is one character. For String, multiple characters may be represented.

Casting is changing the datatype of a variable from a larger datatype to a smaller one. (One cannot cast from a smaller datatype to a larger.) So, if I declare an variable of datatype int, for example:

int myVar = 2147483647

I can cast myVar into a smaller datatype like bit:

(bit) myVar;

Please notice that when casting, I place parentheses around the datatype in the cast statement.

So, myVar which was 31 bits of data as an int becomes one bit of data as a datatype of bit. But, when I do that, the difference in bits is lost or cut off. That is, 30 bits are truncated or cut off. So, after I cast from an int to a bit, the value of myVar (which was 2,147,483,647 when it was datatype int) becomes one since I now only have one bit. To trunctate means to cut off and throw away the rest of the bits that are larger than the new datatype can handle.

Exemplify:
Here's another example of casting. I have this variable declaration:

String myVar = "Hello World";

I cast it into char:

(char) myVar;

Since myVar after it is cast is only one character long, the rest ("ello World!") is truncated or cut off. After I cast myVar down from a String to a char, the value of myVar becomes just the letter, "H".

Why is it that we can cast only from larger to smaller datatypes? Remember that when a variable is declared in Java, memory space in the hardware is set aside for it. For example, if I declare:

int myAge;

the computer sets aside 32 bits in memory for the use of the variable, myAge. I can cast myAge to any datatype smaller than 32 bits because the space is already set aside in the computer. I cannot cast myAge into a datatype larger than 32 bits because there is simply not enough space in the computer's hardware memory set aside for it.

Illustrate:
So, using datatypes in Java and casting is much like buying milk in different sizes of containers. I can have a cup, pint, quart, half-gallon, or gallon container of milk. The milk container size is like the size of the datatype. When I cast from one datatype to another, I could put a cup of milk into a quart sized container. But, I could never fit a gallon of milk into a pint-sized container.

Monday, February 25, 2008

ICA-CP: 2/25/08 - Java data types

Good morning!

We should all be back from Philly, retreat, and other places. So, today we are going to learn more about Java, in particular about Java data types. We will be having a quiz about what we are covering today as well as about all of the material in our blog about file systems, DOS commands, etc. The quiz will be on Friday, and will be 200 points. Be sure you understand the concepts in this blog (which we have reviewed in class at three different times): Class Summary for 1/17/2008 - DOS, file system, and cell hardware There may be some questions about classes similar to those in the Sweet Tooth Factory and Fast Food quizes also.

This week: Work on the Razr programs that were listed in last week's blog. There is a sign off sheet for all of the programs that will be due on Tueday next week, 3/4/08.

Today: We will cover Java data types and work on the Razr programs.
Weds.: Review for the quia on Friday and work on the Razr programs.
Fri.: Take the quiz and work on the Razr programs.
Tues.: Finish up the Razr programs and turn them into me.

Here's what we have for assignments, each worth 30 points:
1) Modify Hello World with your name and run it on the Motorola Emulator (SDK.exe).
2) Load your Hello World on the Razr and run it.
3) Create a ring tone, load it on your Razr and run it.
4) Run the Midway program, dial a number on Midway and have it actually dial the Razr.
5) Load a game program on the Razr and run it.

Question of the week: 2/25/08-2/29/08

[This week's QOW is due on Friday, 2/29/08, by 5:00 PM. Since we meet 3 times, your QOW response should be at least 300 words.]

Question of the week: Computer programs (like Eliza) can imitate people to create logins, access bank accounts, send email, and more. A program to distinguish people from computer programs is called a Captcha. Do you think a Captcha can be effective in distinguishing people from computers? (Be sure to give your reasons why or why not.) How would you use a captcha?

Background: Computer security is a major topic in computer science. One aspect of it is preventing computer generated spams and hacker activities from invading web sites. For example, if a computer program can gain access to YOUR email account, thousands of fake emails can be sent in your name -- and you can be penalized. Web sites like Hotmail, Yahoo Mail, and Google Mail try to keep out spammers and computer programs from creating hundreds of fake email accounts by requiring people to respond to a captcha. From Wikipedia, a captcha is: a type of challenge-response test used in computing to determine whether the user is human.
The full Wikipedia definition is here: http://en.wikipedia.org/wiki/Captcha

More info may be found at: http://recaptcha.net/captcha.html

and at http://www.captcha.net/news/ai.html

One way that spammers get around captchas is by using humans to read and respond to a captcha without the user knowing that he is doing it. Users of porn web sites are often used for this purpose:

"Someone designed a software robot that would fill out a registration form and, when confronted with a CAPTCHA test, would post it on a free porn site. Visitors to the porn site would be asked to complete the test before they could view more pornography, and the software robot would use their answer to complete the e-mail registration.

It's not a practice that rapidly or easily overcame the CAPTCHA test, but the tactic of getting humans to unwittingly do cognitive work for a computer program inspired [Luis] Von Ahn to develop the ESP Game."

The full article is here: http://www.post-gazette.com/pg/03278/228349.stm

ICA-ICP Info: Java Primitive Data Types

First of all, we have some great reference web sites for Java data type info:

Data types explained at the Java tutorial web site
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

From another Java tutorial web site called Cafe Au Lait:
http://www.cafeaulait.org/course/week2/02.html

Info on Java data types:
1) There are built-in data types in Java called primitive data types. Primitive data types include boolean, byte, int, double, and char.
2) There are also additional data types in Java called abstract data types. Abstract data types include String and KeyboardReader.
3) A bit is a 1 or a zero. A byte is 8 bits.
4) boolean: The size is 1 bit. The value is 1 or zero. 1 is true, and zero is false.
5) byte: The size is 8 bits. The value range is -128 to 127. 7 bits are data, and 1 bit is for the + or - sign.
6) int: The size is 4 bytes or 32 bits. The value range is -2,147,483,648 to 2,147,483,647. One bit is for the + or - sign, and 31 bits are data.
7) double: The size is 8 bytes or 64 bits. The value range is 4.94065645841246544e-324d to 1.79769313486231570e+308d.
8) char: The size is 2 bytes or 16 bits. The value range is zero to 0 to 65,535. It uses Unicode, which is a giant lookup table which assigns a character to one of the numbers, to represent the characters.
9) Casting in Java changes one data type to another. A general rule of thumb is that it is safe to cast a smaller sized data type to a larger one, like and int to a double.

Tuesday, February 19, 2008

ICA-CP Info: Using the Midway Tool

The Midway Tool enables the PC to download Java midlets to the Razr. The program comes as a compressed "Zip" file. You have to uncompress it in order to use Midway.

To Unzip the Midway file


1) Go to the C:\Unlock Motorola Cell Phone Programs\SW\Motorola Midway 2.8\ directory
2) Right click on the .zip file and select Unzip --> Extract to Here
3) Winzip will start. Select Use Evaluation Version. Inside of the Winzip program, click the Extract button.
4) There will be several files in your subdirectory now. Read the Using_Midway_2_8.txt file to download programs.


To Use Midway, find the COM port

First, you must find the COM port used by your phone. To find that, follow these instructions from the Using_Midway_2_8.txt file:

For USB, how to know on which COM Port the phone has been detected:

1). Power up the Phone.
2). Connect regular USB Cable to phone.
3). Right Click on My Computer.
4). Click on Properties.
5). Select 'Hardware' Tab.
6). Click on Device Manager.
7). Your phone should be detected as Modem. Expand Modems under Device Manager.
(There has been some cases when the phone is detected as Modem but when you expand
Modems under Device Manager it is detected as Broken link. In this case Reboot the
computer and follow steps 1-7 again)
8). Right Click on "Motorola USB Modem". Select Properties.
9). Select 'Advanced' Tab.
10). Click 'Advanced Port Settings".
11). Note down the COM port number.


To Download with Midway

Your cell phone must have Java unlocked in order to download programs. Do these steps from the Using_Midway_2_8.txt file:
Steps to Download MIDlet.
1). Power up the Phone.
2). Click Menu->Settings->Java Settings->Java App Loader.

If you do not see Java App Loader, you did not unlock your phone correctly. Go back to the 1-tut.pdf file, and follow the steps to unlock your phone again. If you do see the Java App Loader, then continue with the steps to download a file the Using_Midway_2_8.txt file:
Steps to Download MIDlet.
1). Power up the Phone.
2). Click Menu->Settings->Java Settings->Java App Loader.
3). It shows a Dialog on the screen "Insert Cable Now"
4). Insert USB Cable.
5). The phone should display "Jal Link is active."
6). Run MIDway 2.8.
7). Select menu item File->Settings... and change COM Port as it was in step 11.
8). From File Menu on MIDway select "Open JAD..." OR Click on "Open JAD" toolbar icon (1st icon)
9). Select appropriate JAD file from your computer. (Hint: use recent file list in the File menu)
10). Click on "Send JAD" icon (2nd icon). Some information from JAD File will be displayed
on the Phone Screen. If Right Soft Key reads "More" select it. It should then display
"DOWNLD". Select "DOWNLD". This will start downloading the JAR file from computer
to phone. Upon download successful, it starts installing the application.
When installed successfully, the phone displays "Run ?" with YES & NO as soft keys.
If you are planning to download more games, select "NO" otherwise follow steps 8-10 again.

All downloaded applications are listed under "Games & Apps"

ICA-CP: 2/19/08 - Assignments List

Good afternoon!

Here's what we have for assignments, each worth 30 points:
1) Modify Hello World with your name and run it on the Motorola Emulator (SDK.exe).
2) Load your Hello World on the Razr and run it.
3) Create a ring tone, load it on your Razr and run it.
4) Run the Midway program, dial a number on Midway and have it actually dial the Razr.
5) Load a game program on the Razr and run it.

Thursday, February 14, 2008

ICA-CP: 2/14/08 - Happy Valentine's Day?

Good morning!

Be sure to read and study the class blog entry entitled, Class Info: Oh no, I can't find my jad file!!!. Definitely, you will find questions drawn from that blog entry on your quiz on Tuesday. So, this is your reminder that we will have a quiz on Tuesday, 2/19/08. It will cover the contents of the blog and the File System info.

Class Info: Oh no, I can't find my jad file!!!

You've created your Java file and compiled it. It's ready to run in the Motorola emulator (SDK.exe), but oh no, where did it go?

OK, here's what happens in the WindowsXP/DOS file system when you create a midlet using BlueJ.
1) I'm in BlueJ. I click File --> New Project and give my project a name like MyHelloWorldProject. What happens? BlueJ makes a subdirectory or folder and titles it the name of your project. So, I would find a folder with the name MyHelloWorldProject somewhere on my computer. You tell BlueJ ahead of time where to create this folder when you create your new project. A window opens into the file system and usually defaults to the MyDocuments or Desktop folders.
2) Now I make a new class. I click New Class and give it a name like myHelloWorld. What happens in the file system? BlueJ makes a file in the MyHelloWorldProject and calls it MyHelloWorld.java. Since the MyHelloWorld file has the extension of .java, I know that it is my source code file. The source code file is where I enter the Java commands for my program.
3) I've finished entering my Java code, and click the Compile button. If you do not have any mistakes, BlueJ creates a binary file for you with a .class file extension. So, in our example, I would have a MyHelloWorld.class file.
4) Now, I click File --> Create Jar file. Wait! Before you do that, make sure that you have made your manifest.mf file. Remember that a jar file contains the manifest.mf file plus any .class files. Also, make sure you don't have any extra files in the MyHelloWorldProject folder (like from Eliza) or your jar file won't work on the cell phone. Blue makes a MyHelloWorld.jar file in our example.
5) Now, I need a jad file. So, you use Notepad to create your jad file. The jad file, among other items, indicates the size of the jar file so your cell phone can run your program with the right amount of memory. So, you cut-and-paste into a new jad file, edit the info including the size of your jar file, and save it. How do I find the size of the jar file? I use My Computer to find my jar file, right click, and select Properties from the drop-down menu. The size of your jar file in bytes is in the Properties list.

Tuesday, February 12, 2008

ICA-CP: 2/12/2008

Good morning!

This morning, we will review for our Friday quiz. Then, we need to continue our efforts to get the Razr to talk to our computers -- with the goal of getting your Hello World program to run on the Razr.

Friday, February 08, 2008

ICA-CP: 2/8/08

Good morning!

I know we're experiencing technical difficulties. Goad for today: Get your hello world to run in the simulator. Then, once it runs in the simulator, download it to the cell phone and run it on the Razr.

Monday, February 04, 2008

ICA-CP: 2/4/08

Good morning!

Please check due dates this week. Today, this is what is due:


Monday, 2/4/08 - MyHelloWorld printout from Motorola simulator due.

On Weds., we have a quiz.

Sunday, February 03, 2008

Question of the Week: 2/4/08-2/8/08

[For this week, since we have three meetings, your Question of the Week response should be at least 300 words in length. It is due by 5:00 PM on Friday, 2/8/08.]

Question of the Week: Why do you (or don't you) play as many games on a cell phone as you would on a computer or game deck (like Wii or Xbox, etc.)?

Background: According to an ATT advertisement brochure called Guide to Wireless 1Gaming, 40% of mobile phone subscribers between the ages of 13-17 play mobile games. So, it is very likely you play games on your cell phone. However, playing cell phone games across the population of all cell phone users is not a widespread activity. An article entitled Why Aren't People Buying Cell Phone Games? at http://blog.wired.com/games/2007/03/why_arent_peopl.html and another, Obstacles slowing mobile game growth, at http://www.hollywoodreporter.com/hr/content_display/features/columns/playing_games/e3i10632efd792bb24ade2e8e1833895f9c?imw=Y explain the problem. One problem may be price. Some games which used to be free now cannot be found. For details see Can You Play Me Now? at http://www.slate.com/id/2176391/fr/rss/.