Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBen Jakuben
Treehouse TeacherForum Contest: Build an Android Clock App
EDIT: This contest has ended! Congratulations to Jonathan Baker for the winning entry! Our next contest on creating an HTML5 game is up!
Hello Android developers!
This week's Forum Contest is once again for Android. Let's build some clock apps!
After you've watched the video, please read the details below carefully. We're looking forward to your entries!
Contests Rules:
This contest is pretty open ended. The main objective is to display the current time, and it must update at least for each minute change. Everything else is up to you. It can be analog or digital, abstract or skeuomorphic. Feel free to add additional features, but the clock itself is the most important component. Create your app as a native app; i.e. the app must be installable on Android devices (web apps are not permitted).
How to Enter:
Post a link as an answer to this post. It can be a link to downloadable project files or a GitHub repo. If you want to submit a link to an app on Google Play (you're encouraged to publish your entries!), then also provide a link to the source code. Source code is required for this contest.
Due Date:
All entries must be submitted by May 4th at 11:59pm ET. Here's a timezone chart so you can see what time that is for your locale.
Prize:
The entries will be judged by Treehouse teachers based on both design and code. One winner will receive a free month of Treehouse Pro (formerly called "Gold") on us! We'll announce the winner on May 5th and reveal the next contest.
29 Answers
John Coffin
10,359 PointsCan this get marked as "featured" so that is easy for all to find?
John Coffin
10,359 PointsIn the spirit of competitive collaboration (or is it collaborative competition?), I think that "android.intent.action.TIME_TICK" might be a good way to go:
"Broadcast Action: The current time has changed. Sent every minute."
Thoughts?
Ben Jakuben
Treehouse TeacherA great option! Thanks for sharing. :) Not the only option, though, if anyone is intimidated by registering a receiver for the broadcast. It should be a good learning experience if you go this route, though! We will cover broadcasts and receivers in a future project.
Danny Graham
812 PointsAn hour ago I was meditating and I got a thought saying "I should make an alarm clock app" now this pops up. Huh, weird! Maybe it's a sign.
David Klein
Courses Plus Student 1,456 Pointswhere can i find iOS challenge?
John Coffin
10,359 PointsSame place. You just need to be patient as there is only one challenge per week, and it rotates around from topic to topic.
Is there any reason that this cannot be an Android and/or iOS challenge? There is an overlap (i.e. they both have Ribbit apps).
Ben Jakuben
Treehouse TeacherYou all must be peeking ahead! We're limiting it by topic area and will have an iOS contest to match soon. :)
Jason Thorn
2,611 PointsWould love to give this a go! Not quite there yet though :(
Ben Jakuben
Treehouse TeacherIt doesn't have to be fancy, and it would be a great learning experience!
Lee Smithson
3,598 PointsTotally. It could be as simple as displaying the current system time in a TextView (right? haha). I mean, like Ben Jakuben said, it will be a learning experience either way.
Jason Thorn
2,611 PointsYeah you guys are right :). You don't know until you try!
Lee, you stole my idea!! :D
Lee Smithson
3,598 Pointslol! No worries; that's not what I'll be doing ;) I've been doing Android for a good bit, so I'm gonna try and do something fun.. see what I can learn as well. :)
John Coffin
10,359 PointsDone and done. Here's my Stage 1
So ... this displays the current system time in a TextView. I don't even adjust the size of the text. It just updates on the minute. Very simple. It barely makes the minimum requirements. I won't win any contests, but it will beat anyone who doesn't enter.
I can go anywhere from here; the world is my oyster. The neat part about tackling this is that I had a TON of ideas of how to make the clock interesting (which I wrote down rather than running off and trying to do all of them). When I was sitting around in the white-boarding stage (i.e. before coding), I had zero ideas of how to make this interesting.
Ben Jakuben
Treehouse TeacherExcellent work! And 10 bonus points for being first to post!
Ben Junya
12,365 PointsOoo, this is going to be fun!
Got some idea for animations and stuff while driving around yesterday - I'll start coding! Once I finish the android track :/...
John Coffin
10,359 PointsI've given up on my "Sudoku Clock" idea for now. If there is anyone here who wants to run with that one, be my guest.
Ben Jakuben
Treehouse TeacherThat's too bad - sounds like it would have been very interesting! :-)
Rémi BRUGUIER
4,970 PointsTime to start the android lessons then ! I Hope I'll be able to produce something before the deadline... Good Luck to all !
Jason Thorn
2,611 PointsWell after some gentle persuasion from Ben & Lee, Here it is: https://github.com/lilsancho/simplest-clock I know it's not the nicest and probably not the best put together app but I've used what I've learned from the Crystal Ball lessons & some of my previous C & C# studies (and a bit of googling). I guess the main thing is that it works!! But I look forward to feedback on better ways to have done it :)
P.S I'm just waiting it to go through on the play store, I'll post a link when it's up.
Erin Masterson
6,853 PointsI followed the lesson on animationdrawable precisely and I am running into a problem with my animation being null. I have a really cool plan for the clock though. Anyway, I tried getDrawable instead on the imageview and it still didn't work. Any thoughts?
John Coffin
10,359 PointsPost the portion of your code that loads the animation and we can have a boo. More eyes means a better chance of us finding it.
Or if you're on github and are not worried about anyone stealing your idea (maybe you have not implemented that part yet), give us a link.
John Coffin
10,359 PointsSorry that this took so long. A bit of a needle in a haystack.
The problem is the selector in your animation file. You have something like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<animation-list android:id="@+id/rocket_thrust" android:oneshot="false">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
</selector>
It will work if you change it to something like this:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
I'm sorry that I can't explain why this is a problem, but I do know that by changing it you can move on to the next step.
Erin Masterson
6,853 PointsThanks very much
Jonathan Baker
2,304 PointsHere's my take on an abstract looking clock app. It's somewhat inspired by Tron Legacy in design.
Here's the source: https://github.com/cocoahero/android-tron-clock
Lee Smithson
3,598 PointsVery cool! That'll be a fun one to learn from later on :)
Jason Thorn
2,611 PointsThat looks awesome! I spent ages trying to figure out how to draw a circle like that. Your code will certainly help me out on that front :) Thanks for sharing.
Erin Masterson
6,853 PointsI am having trouble with my timertask. It keeps crashing the app
Jonathan Baker
2,304 PointsWithout seeing what exception is occurring, it's hard to tell what's wrong. But my first guess is you are probably updating the UI from within the TimerTask. Timers (and the corresponding task) are run on a separate thread other than the main thread. You must only update the UI from the main thread.
John Coffin
10,359 PointsJonathan: I am coming up against a similar challenge. What is the best way to tell the main thread to update the UI from a timer or something else that is on a separate thread? Should we use post? Can we launch an Intent? Or is AysncTask the way to go?
Jonathan Baker
2,304 PointsYou can definitely use View#post to get back on the main thread. Another route you can go is by using a dedicated Handler instance to handle main thread functions.
If you check out my code, I use View#post to update the TextView.
Rémi BRUGUIER
4,970 PointsHello again everybody,
Being totally new to the whole Android Development concept, I just had the time to follow the CrystalBall lessons and try to make something fun out of it. My clock concept is kinda far-fetched but, hey, I did what i could with my limited skills :D
Let's say you are a WebDesigner, and want to find great colors and fonts for your next project whilst checking the time (erm ... why not !!). Well then you can use my Webdesigner Clock Application !
Swipe to the left: changes the background color (with a transition effect) with one picked from flatuicolors.com
Swipe to the right: changes the font with one picked from FontSquirrel amongst the most popular ones.
Shake your device : Resets the background color and the font with a sound effet :3
Includes a custom launcher icon.
Had a lot of fun making that little thing even though it's a quite limited tool... Thanks for the contest, looking forward to the next one!
Ratik Sharma
32,885 PointsHello everyone! I'm new here. Honestly, I joined about an hour back. But, I have been following this contest for a few days now and I did make an app to submit.
My submission: http://bit.ly/1kNae0S
Swipe to the left: brings up the settings
Looking forward to the next context!
Ben Jakuben
Treehouse TeacherWow, I absolutely love what you all have submitted so far. It is going to be super hard to choose a winner. Can't wait to see if anything else comes in before midnight tonight! I'll post the winner tomorrow morning.
Rémi BRUGUIER
4,970 PointsIf you have the time to make one, can you show us your clock ? :D (better not mispell that word)
Ben Jakuben
Treehouse TeacherLOL I don't have anything to show for this contest, actually. If I make something this week I'll post it here, though.
y0mki
14,218 PointsHello everyone! Here's what I came up with. I tried to keep it as simple as possible and I learned a lot from it. Here's a screenshot of my app:
And here's the GitHub link to it. I'm looking forward to the next contest! :-)
Erin Masterson
6,853 PointsHelp! I was about to turn in my entry when Android stopped recognizing a bunch of things all of a sudden and 62 errors that werren't there before! Mostly R stuff. Can I submit it anyway? Maybe someone can fix it
Rémi BRUGUIER
4,970 PointsHappend to me once.. I just restarted eclipse and all was fine again...
John Coffin
10,359 PointsSorry, but I just saw this now. Is GitHub up-to-date? If not, commit the latest changes and post the link. I'll try to run it. It may be that your code is fine but something on your dev PC is wonky.
John Coffin
10,359 PointsPS And yes please submit it. We are all excited to see it.
Ben Jakuben
Treehouse TeacherI'm about to start my final review, but if you have a link to post I'll try to look at it and troubleshoot before I'm done! Or if you don't get this message, you can still post your code for help in getting it working. :)
Erin Masterson
6,853 PointsI'm uploading it now, I hope I can still be considered. I put it on 4shared cause my website wouldn't accept the filesize.
Ben Jakuben
Treehouse TeacherAbsolutely amazing timing. I just opened your other project to take a look. Saved yours for last in case you had another link like this. Downloading now!
Erin Masterson
6,853 PointsCouldn't figure out the git stuff as I am a bit new to it. Also I was rushing to recreate the project so please ignore the generic com.example stuff I didn't have time to change
Erin Masterson
6,853 Pointsthis is an emergency, I had almost everything ready
Erin Masterson
6,853 PointsSetcontentview isn't working either
Erin Masterson
6,853 PointsSetcontentview isn't working either
Lee Smithson
3,598 PointsAh! Want to comment the link before I let the minute pass haha. I need to commit something too.
Anyway, link!
Lee Smithson
3,598 PointsDagggg nabit! Couldn't finish my last commit in time. Disregard. XD haha.
You can at least see where I was going with it.
John Coffin
10,359 PointsSigh. I didn't get the animation to work in time.
Ben Jakuben
Treehouse TeacherOkay, this was a tough one! You all are amazing and inspiring. I absolutely loved all the approaches taken here. Even the simple ones were great to see and had good code.
This was a really hard choice, but after consultation with a few other Treehouse team members, we've decided to declare Jonathan Baker as the winner with his Tron-themed clock. Congratulations, Jonathan!
Jonathan's design was simple but sharp. He created a custom view for the three circles that I highly recommend you review. It's a great example of how to create a custom view and use it in a layout. He used the Timer method to post changes to the clock, and his code is also a good example of how to update the user interface (main) thread from a background thread that was spawned by a timer task.
Please check out the rest of the submissions for more inspiration! I want to sing the praises of each entry, but here's a brief summary so you can get on to the next contest. :)
John Coffin used the BroadcastReceiver model for the clock, which is a great approach and introduction to subscribing to system broadcasts.
Jason Thorn's clock was another simple and sharp design that displayed the days of the week above the time with the current day highlighted. Updated each second.
Erin Masterson had a few minor issues in the code, but I love where it was headed! The highlight is a hamster ball that moves across the screen over the course of a minute.
Remi Bruguier has swipe and shake detectors and a great transition scheme as you change the background color. He also has a good example of how to use a custom font in your project.
Ratik Sharma has an elegant all-word clock that takes advantage of "immersive" mode for KitKat users. I loved this more abstract design!
Art Lleshi had a simple and elegant design that resembled the stock clock app. He also used the BroadcastReceiver method to keep the time in sync with the system clock.
Lee Smithson had a very fun abstract text clock. He also used Roboguice to inject views in his Activity, which was major bonus points for me. I love Roboguice and will cover it in a workshop at some point.
Again, fantastic work everyone, and thanks for participating! Oh, and stay tuned for the next Android project, due next Monday!
Rémi BRUGUIER
4,970 PointsCongrats Jonathan, well deserved. And thanks Ben to take the time to review every single project, it feels good to know that our work was meticulously checked.
David Klein
Courses Plus Student 1,456 PointsHi Jonathan Baker , First, congratulation for being a winner. Btw, it is possible for you to port this android tron clock style to iOS, I'm very grateful if you do so. I hope i can learn from you and others guys.
Ratik Sharma
32,885 PointsGah! I had a feeling Jonathan was going to win. Congrats, mate!
Request: Any and all criticism regarding the Word Clock I made is appreciated. I plan on publishing that app so, it would be cool if you guys could let me know about any flaws or things I should look into. Thanks!
Ben Jakuben
Treehouse TeacherHey Ratik! Sorry for the delay...I had been focusing on getting my latest project published. I had a few other brief notes about your project:
- Check out the TextClock. I think there were some things that could make some of what you were doing easier, but I don't quite remember.
- +1 for immersive mode for KitKat users :)
- I liked how you could swipe for the settings, but I didn't like having to restart the app to change the theme. I wonder if you could implement it dynamically somehow? I remember thinking that would be possible with your code.
Glad you are going to publish it! Drop a link in here when you do!
Jonathan Baker
2,304 PointsThanks everyone! I hope that the source code will be beneficial to all of you in your future learning adventures.
David Klein
Courses Plus Student 1,456 PointsiOS source code please Jonathan Baker . :)
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherDone! It's supposed to be, but there's a bug in our system that reverts them if we make any edits. I forgot to check it again when I made an update after posting it.
John Coffin
10,359 PointsJohn Coffin
10,359 PointsAwesome! Thanks.