[ClockApps] - Countdown Timer and Stopwatch

Search for BETA-testers and/or promote your own Application in a decent way.

[ClockApps] - Countdown Timer and Stopwatch

Postby noamwolf » Sun Nov 23, 2008 1:07 am

Promoting my application, please let me know what you think.

Applications > Tools > Clock Apps.

I'm willing to show source if anyone is interested.
Attachments
clockapps3.png
Settings.
clockapps3.png (31 KiB) Viewed 20357 times
clockapps4.png
Timer stopped, buttons enabled, hour column hidden.
clockapps4.png (37.25 KiB) Viewed 20357 times
clockapps2.png
Stopwatch done, laps showing.
clockapps2.png (27.81 KiB) Viewed 20357 times
clockapps.png
Timer running, buttons disabled, hour column showing.
clockapps.png (32.49 KiB) Viewed 20357 times
Last edited by noamwolf on Sun Dec 07, 2008 2:27 am, edited 1 time in total.
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Top

Postby MrSnowflake » Sun Nov 23, 2008 1:15 pm

Nice, there are always situations where you need such timers :).

How did you implement the shake to reset? Is running with it also shaking? (could I get your shake to reset code, maybe?)
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby noamwolf » Sun Nov 23, 2008 4:24 pm

So the shake to reset is actually kinda fragile at this moment. The threshold i set is kind of iffy and I intend to add it to the pref menu (as in, choose the shake to reset threshold: Light shake, just shake, hard shake).

Anyway the code is based off of the API's OS example for sensors, I pretty much copied it from there (I'm not on my dev box right now but I would be happy to send you the exact code if you still want it).

HTH
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Postby MrSnowflake » Sun Nov 23, 2008 4:43 pm

Yeah, I'd like to see it.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby noamwolf » Sun Nov 23, 2008 4:47 pm

Heres my listner, notice the threshold, the higher it is the lighter you have to shake the device.

Again this is not the best solution, but it works for now.

Also, remember that you have to register this listener.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private SensorListener sensorListener = new SensorListener() {
  3.  
  4.     public float accelerometer_shake_threshold = 50000;
  5.  
  6.     static final int ACCELEROMETER_FLOAT_TO_INT = 1024;
  7.  
  8.  
  9.  
  10.     public void onAccuracyChanged(int sensor, int accuracy) {
  11.  
  12.     }
  13.  
  14.  
  15.  
  16.     public void onSensorChanged(int sensor, float[] values) {
  17.  
  18.       synchronized (this) {
  19.  
  20.         if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
  21.  
  22.  
  23.  
  24.           int ax = (int) (ACCELEROMETER_FLOAT_TO_INT * values[0]);
  25.  
  26.           int ay = (int) (ACCELEROMETER_FLOAT_TO_INT * values[1]);
  27.  
  28.           int az = (int) (ACCELEROMETER_FLOAT_TO_INT * values[2]);
  29.  
  30.  
  31.  
  32.           int len2 = (ax * ax + ay * ay + az * az) / 1000;
  33.  
  34.  
  35.  
  36.           if (len2 < accelerometer_shake_threshold) {
  37.  
  38.             clockAppsReset();
  39.  
  40.           }      
  41.  
  42.       }
  43.  
  44.     }
  45.  
  46.  
  47.  
  48.   };
  49.  
  50.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Any comments/feedback would be greatly appreciated.
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Postby MrSnowflake » Sun Nov 23, 2008 5:49 pm

Your code register a looong acceleration in 1 direction too as a shake, doesn't it?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Postby noamwolf » Sun Nov 23, 2008 5:54 pm

Not sure I understand what you're asking. You can shake in any direction.
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Postby MrSnowflake » Sun Nov 23, 2008 5:59 pm

But if you keep accelerating in 1 direction, it will also register as a shake, won't it?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby noamwolf » Sun Nov 23, 2008 6:08 pm

ah i see what you're saying. Yes, probably. Any suggestions on how to fix it?
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Postby MrSnowflake » Sun Nov 23, 2008 6:20 pm

No, that's why I wanted your code :D
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Re: [ClockApps] - Countdown Timer and Stopwatch

Postby infotechsailor » Tue Dec 02, 2008 4:54 am

noamwolf wrote:Promoting my application, please let me know what you think.

Applications > Tools > Clock Apps.

I'm willing to show source if anyone is interested.



I'm interested in this code... I'm a Java and Android n00b... but I would like to implement a simple countdown timer in my application that can be set by the user the stop/started.

If you would like to help me with my app... I would appreciate it... just a learning experience for my first app...

Thanks!

--Josh B.
infotechsailor
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Dec 02, 2008 4:49 am

Postby noamwolf » Tue Dec 02, 2008 6:09 am

Sure, i would be glad to help. Start off by looking at CountDownTimer http://code.google.com/android/referenc ... Timer.html

Try to figure it out, then if you have a specific question feel free to email me.
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Version 1.0.16 is out

Postby noamwolf » Sat Dec 06, 2008 5:13 pm

I put out an update that fixes some bugs that have been reported. Check it out and please rate and write a review ;)

Thanks!
noamwolf
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 23, 2008 12:56 am

Postby wolfmankurd » Sat Jan 02, 2010 11:26 pm

noamwolf wrote:ah i see what you're saying. Yes, probably. Any suggestions on how to fix it?


This is dependant on a large absolute acceleration? A shake would have an overall movement of zero. So maybe checking for +ve acceleration followed by -ve acceleration, I don't know how this would be implemented. Cause I'm a n00b.
wolfmankurd
Freshman
Freshman
 
Posts: 4
Joined: Sat Jan 02, 2010 11:22 pm

Postby giridhari » Sun Feb 14, 2010 6:57 am

Can you show me the code for stop clock ?
giridhari
Freshman
Freshman
 
Posts: 2
Joined: Sun Feb 14, 2010 6:55 am

Top
Next

Return to Promote your Android Application

Who is online

Users browsing this forum: No registered users and 1 guest