mark.meretzky@nyu.edu
)
the differences between the PC and Mac installations.
The Facebook group for our course is
App
Development Intensive INFO1-CE9416.
Create a free
GitHub account
and email me
(mark.meretzky@nyu.edu
)
its name.
Please add a
picture
of yourself
to your GitHub account.
Look at the GitHub accounts of
your classmates
and
last semester’s students.
Click on the Repositories tab of each student.
Look at my
Hello
project and press the Download ZIP button in its lower right corner.
Unzip the file if your web browser has not already unzipped it for you.
Then in Android Studio,
you can pull down
File → Open…
and select the Hello folder that was unzipped from the ZIP file.
You’re probably dreaming of creating an app that reads and writes a remote database on a server somewhere. We’ll do that later in this course. For now, start looking at the databases at NYC OpenData, starting with the restaurant inspection results. If you want, you can see how we loaded the restaurant inspection results into an sqlite database last semester. On June 6th, we’ll have a brief in-class oral report about the New York City databases. (The only urban area in the United States that has a remotely comparable set of databases is the San Francisco Bay Area.)
If you want more than the crude primary colors we made with
00
,
80
,
and
FF
,
the graphic design guidelines for Android—colors, margins, fonts—are
here.
Study XML. Run Hello and do the exercises in Hello, RelativeLayout, LinearLayout, but don’t hand them in. Do exercise 12 in LinearLayout, and upload it to your GitHub account. Look at the other students’ apps too.
Want to learn to program?
Write an app named
Prev
that has the class
Date
in
Class.
Add a no-parameter method named
prev
to the class.
It will be just like the existing no-parameter method named
next
,
except that it will make the
Date
object go
backwards
one day instead of forward one day.
Test it with the following loop.
Be sure to try out borderline cases like
December 31, January 1, January 31, etc.
Post this app on GitHub.
//----------------------------- for (;;) { int month = getInt("Month", "Type in the month (1 to 12)."); int day = getInt("Day", "Type in the day of the month."); int year = getInt("Year", "Type in the year."); Date d = new Date(month, day, year); String output = "The day before " + d; d.prev(); output += " is " + d + ".\n"; display("Previous day", output); } //-----------------------------
Also write an entertaining app named
Jun6
(not June6
) and upload it to your
GitHub
account by June 13th.
It’s okay if you want to start with the
Bed
app and modify it as we did all day long on June 6th.
You can do input with the methods I wrote in that app:
getInt
,
getLong
,
getBoolean
,
getFloat
,
getDouble
,
getString
.
You can do output with
display
,
or with a piece of
toast,
or by writing into a
TextView
as we did in the last “isConnected
”
example in
Before Objects.
How about something totally idiotic like
//----------------------------- for (;;) { String response = getString("Knock-knock Joke", "Tell me a knock-knock joke."); response = getString("", "Who's there?"); response = getString("", response + " who?"); display("Ha ha", "Ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha!"); } //-----------------------------Or you could use an array of strings and a loop to display the lyrics to “A Partridge in a Pear Tree” or “Green Grow the Rushes O” or “There’s a Hole in the Bottom of the Sea” or something like that. Unicode characters like π or ש are always a plus. If you’re using more than one color, pick a set of related colors from the color palette, and browse around in this material design document.
Write something interesting named
JUN13
.
For example,
go to
Change Listener
and follow the links I made to the source code of the
“Views → Rotating Button” example.
Using that technology, make a
SeekBar
that moves a
TextView
upwards as in
this animation.
To prepare for the
Programmatically
app we will do on June 20th,
look at our two examples of
View
s
created by Java rather than by XML:
the “Three TextViews” created by the
for
loop in
Before Objects,
and the row of
TextView
s
created by the
buildChart
method of the
MainActivity
of this
JUN6
project.
On June 20th, I’ll bring in my Samsung Galaxy IIs phone
and you can help me figure out how to make
adb
devices
and Android Studio notice it.
We will have a class on Sunday, August 9, 2015, because this course has only 13 Saturdays. See my Fall 2015 Android teaching schedule in my home page; although the courses have different numbers, they cover the same material you’re taking now.
int color; if (i == 0) { color = 0xFFFF0000; } else if (i == 1) { color = 0xFFFF8000; } else if (i == 2) { color = 0xFFFFFF00; } else if (i == 3) { color = 0xFF00FF00; } else if (i == 4) { color = 0xFF0000FF; } else if (i == 5) { color = 0xFF4B0082; } else if (i == 6) { color = 0xFF7F00FF; } else if (i == 7) { color = 0xFF808080; } else if (i == 8) { color = 0xFFD2B48C; } else { color = 0xFF000000; } textView.setBackgroundColor(color);
int color; if (i == 0) { color = Color.RED; } else if (i == 1) { color = Color.rgb(0xFF, 0x80, 0x00); //orange } else if (i == 2) { color = Color.YELLOW; } else if (i == 3) { color = Color.GREEN; } else if (i == 4) { color = Color.BLUE; } else if (i == 5) { color = Color.rgb(0x4B, 0x00, 0x82); //indigo } else if (i == 6) { color = Color.rgb(0x7F, 0x00, 0xFF); //violet } else if (i == 7) { color = Color.rgb(0x80, 0x80, 0x80); //gray } else if (i == 8) { color = Color.rgb(0xD2, 0xB4, 0x8C); //tan } else { color = Color.BLACK; } textView.setBackgroundColor(color);
See the Chinese years example here.
int[] colors = { Color.RED, Color.rgb(0xFF, 0x80, 0x00), //orange Color.YELLOW, Color.GREEN, Color.BLUE, Color.rgb(0x4B, 0x00, 0x82), //indigo Color.rgb(0x7F, 0x00, 0xFF), //violet Color.rgb(0x80, 0x80, 0x80), //gray Color.rgb(0xD2, 0xB4, 0x8C) //tan }; int color; if (0 <= i && i < colors.length) { color = colors[i]; } else { color = Color.BLACK; } textView.setBackgroundColor(color);
The
if
statement can be telescoped to
final int color = 0 <= i && i < colors.length ? colors[i] : Color.BLACK;
Button
s)
numbered 1, 2, and 3,
and a
TextView
inviting you to pick one of the doors.
Each door would lead you to a different screen,
probably containing an
ImageView
or a view displaying graphics that you programmed yourself.
Touch
used a Java
switch
statement.
I added a few
switch
examples to
Before Objects.
Later this semester, we’ll create a database containing a table containing the most recent inspection of each New York City restaurant. Here is the example that Sam Sultan told us how to do on June 20th.
I’ll bring my Samsung Galaxy IIs phone on June 27th and you can figure out why Android Studio ignores it. Visit my one-day iOS tutorial on Monday, July 20th at the DevCon5 conference.
View.OnTouchListener
to a simpler
View.OnClickListener
.
Write and upload an app named
Jun27
that is similar to
Collective.
It will have a
MainActivity
that displays a
Button
that launches a second
Activity
.
(In
Collective,
the second
Activity
is named
MarkActivity
.)
The second
Activity
will do something interesting.
(In
Collective,
the second
Activity
does three animations.
Your second
Activity
could draw graphics, do animation, tell jokes, use the accelerometer, etc.)
In addition, the second
Activity
will display nine buttons to launch nine other
Activity
s
belonging to nine other apps.
When you begin to create your
Jun27
app,
Android Studio will ask you for your Company Domain.
Give it one of the following names,
depending on who you are:
abdoulaye.scps.nyu.edu
alrick.scps.nyu.edu
asa.scps.nyu.edu
david.scps.nyu.edu
deepali.scps.nyu.edu
jaxon.scps.nyu.edu
jeffrey.scps.nyu.edu
joey.scps.nyu.edu
keenen.scps.nyu.edu
mark.scps.nyu.edu
Your
Jun27
app will contain two subclasses of class
AppCompatActivity
.
One subclass will be the usual
MainActivity
class we’ve had all along.
The second subclass of
AppCompatActivity
will have one of the following names, depending on who you are:
AbdoulayeActivity
AlrickActivity
AsaActivity
DavidActivity
DeepaliActivity
JaxonActivity
JeffreyActivity
JoeyActivity
KeenenActivity
MarkActivity
Your
MainActivity
should have a
Button
that launches your second subclass of
AppCompatActivity
.
We saw how to do this in class on June 27th in
this project;
see the
<activity>
element in
lines 22–26
of
AndroidManifest.xml
and the
Intent
object in
lines 36–37
of
MainActivity.java
.
(Read
• To start an activity
and
• Explicit intents.)
Your second subclass of
AppCompatActivity
should do something interesting.
In addition,
it should display nine
Button
s
that launch the nine other
AppCompatActivity
s
in the above list.
To run your app,
install your
Jun27
app and your classmates’
Jun27
apps (including
my Jun27 app)
on your emulator or phone.
Then run your
Jun27
app.
For
the instructor’s 60th birthday hike
on Sunday, July 12, 2015,
take the 7:43 am Metro-North
Hudson Division
train from Grand Central Terminal in Manhattan to the
Breakneck
Ridge
station in Dutchess County
(arriving 9:09 am).
Objective: the
Mount
Beacon Fire Tower,
elevation 1602 feet above sea level.
On the U. S. Geological Survey
West Point quadrangle
(in the 7½′ series),
it’s the “Lookout Tower” on
“South Beacon Mtn”
at
41°
28′
53.1″
North
73°
56′
40.7″
West.
On the Hudson Highlands State Park
trail
map,
we’ll go from the Hudson River up to the fire tower along the white line
(BR, the Breakneck Ridge Trail)
closely following the Putnam/Dutchess border.
We’ll go back down along the red
(CT, the Casino Trail),
probably getting back on the Hudson Division train at the
Beacon station.
See the Wikipedia articles for
Breakneck Ridge,
Mount Beacon,
the
Incline
Railway,
Bannerman’s
Island,
etc.
The
view will extend from the Freedom Tower to the Catskill Mountains;
see
PeakFinder
and the
view
of the Beacon reservoir from the fire tower.
Bring a full day supply of food and water.
The last shot of Alfred Hitchcock’s
North by Northwest
is a train entering the Breakneck Ridge tunnel.
The official tree of Breakneck Ridge is the
chestnut oak.
Weather
at the fire tower.
Write an app named
Jul11
(uppercase
J
,
lowercase
ul
,
eleven)
containing at least two subclasses of class
AppCompatActivity
:
MainActivity
and
YournameActivity
,
where
Yourname
is your first name as listed in last week’s assignment.
When you begin to create the app with Android Studio,
specify your company domain as
yourname.scps.nyu.edu
.
The
package
statement at the top of your
.java
files will therefore say
edu.nyu.scps.yourname.jul11
.
Your
MainActivity
will display a
spinner
with ten items or a
list
with ten items.
Nine of them will run the
MainActivity
of the
Jul11
apps of the other students (including David and me).
The item with your name will run the
YournameActivity
of your
Jul11
app.
YournameActivity
should do something interesting,
probably involving graphics, animation, gesture recognition, beeping sounds,
Spinner
s,
ListView
s,
the contacts data base,
etc.
Change the
string
resource
app_name
in
strings.xml
to
"Jul11 Yourname"
.
For a complete example, see
8 Ball.
Visit my one-day iOS tutorial on Monday, July 20th at the DevCon5 conference.
Your instructor just put his very first app on his brand new Amazon fire HD6 tablet, with 6-inch display and ultra-fast quad-core processor, front and rear facing video cameras, and an incredible selection of over 33 million movies with free unlimited cloud storage. Here’s the screen shot (800 × 1280) and the list of threads:
adb devices List of devices attached 0088080744830RTG device adb devices -l List of devices attached 0088080744830RTG device usb:14100000 product:full_ariel model:KFARWI device:ariel adb -s 0088080744830RTG shell Allow USB debugging? OK shell@ariel:/ $ ps USER PID PPID VSIZE RSS WCHAN PC NAME root 1 0 972 492 ffffffff 00000000 S /init root 150 1 518100 24508 ffffffff 00000000 S zygote u0_a0 3529 150 542972 29968 ffffffff 00000000 S edu.nyu.scps.hello shell@ariel:/ $ ps -t 3529 USER PID PPID VSIZE RSS WCHAN PC NAME u0_a0 3529 150 542972 29968 ffffffff 00000000 S edu.nyu.scps.hello u0_a0 3533 3529 542972 29968 ffffffff 00000000 S GC u0_a0 3534 3529 542972 29968 ffffffff 00000000 S Signal Catcher u0_a0 3535 3529 542972 29968 ffffffff 00000000 S JDWP u0_a0 3536 3529 542972 29968 ffffffff 00000000 S Compiler u0_a0 3537 3529 542972 29968 ffffffff 00000000 S ReferenceQueueD u0_a0 3538 3529 542972 29968 ffffffff 00000000 S FinalizerDaemon u0_a0 3539 3529 542972 29968 ffffffff 00000000 S FinalizerWatchd u0_a0 3540 3529 542972 29968 ffffffff 00000000 S Binder_1 u0_a0 3541 3529 542972 29968 ffffffff 00000000 S Binder_2 shell@ariel:/ $ exit
Play with the SQLite examples in Play with SQLite. I finished the example in the “Frequency” section. Click on the cartoon.
Write an app named
Jul25
that will create an SQLite database containing at least one table.
The table must have a column declared as
_id integer primary key autoincrementYour app should create, update, and delete records from the table. For example, your table could have two columns,
x real, y realto keep track of the points where the user touched the screen. (Use a
View.OnTouchListener
.)
We took
Joey’s
Java program
Hangman
and turned it into an
Android app.
You would learn a lot about programming if you rearranged the logic
so that the
Game
is the higher-level object and the
Prompter
is the lower-level object.
For example, the
play
method,
which contains the
main loop
of the game,
belongs up in class
Game
,
not in class
Prompter
.
And low-level methods that perform and validate input,
such as
validateGuess
,
belong down in class
Prompter
.
To sum up,
the
Prompter
object should be plugged into (or contained by) the
Game
object,
not vice versa.
I just put
my first cloud example
online!
Thank you for your help—there’s no way
I could have done this on my own.
Remember, I learned to program back in the punch card era.
Run the example in
Parse
and select Refresh from the three-white-dots menu to see if anyone else
is running the app.
[Wednesday, August 5: at least one person has run the app so far!
He or she changed
“Bob Hope”
to “Bob Despair”.
But they spelled “Despair” wrong.
Please update the row again.]
Then write an app named
Aug1
that will read and write rows in a table in the cloud at Parse.com.
Would anyone like to investigate
push
notifications?
The book I mentioned is
Arduino + Android Projects
for the Evil Genius
by Simon Monk.
My entire website (including the class website) has moved to
http://oit2.scps.nyu.edu/~meretzkm/
.
Aug8
that does something.
(Database?
Parse.com?
GPS?
Google map?
Regular expressions?)
0_0_0.png
and
1_0_1.png
),
go to
mandelbrot.html
and zoom and drag.
For the tiles of the Unicorn tapestries, go to
Capturing
the Unicorn
and search for the word “tile”.
Is there any way we could get these Unicorn tiles?
What would be an example of rows and columns of images we could
display with Google maps?
Or a series of images at different zoom levels that we could cut up into
rows and columns?
Newflash: [Tue Aug 11 19:53:30 EDT 2015] I just got the Java class MapView to work.
Macintosh OS X 10.10.5 and Android 6.0 (API 23) are now available.
In Android Studio, pull down
Tools → Android → SDK Manager
Launch Standalone SDK Manager
For an example of a new
build.gradle
file, see the
build.gradle
of
VideoView.
Write something simple but interesting.
Hey, we now know how to parse XML
(see
XML_Parser_Experiment
and
XML_Parser_Experiment-master
)
as well as JSON, right?
WebView
play an mp4 video file on the Genymotion Samsung Galaxy S5?
I corrected
MediaPlayer
so that it re-creates a pristine
AsyncTask
and
SeekBar
when you change the orientation of the device.
I updated the huge shellscript in
Violation
so that you would have to change only one line
(selectedzipcode=10003
)
to retarget it for a different zipcode.
Write something simple but interesting, probably involving still photos, video, or audio, and upload it to GitHub. We’ll have an in-class oral report about Android and Arduino on August 29th.