| Author |
Message |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sun Nov 23, 2008 1:07 am Post subject: [ClockApps] - Countdown Timer and Stopwatch |
|
|
Promoting my application, please let me know what you think.
Applications > Tools > Clock Apps.
I'm willing to show source if anyone is interested.
| Description: |
|
| Filesize: |
31 KB |
| Viewed: |
7204 Time(s) |

|
| Description: |
| Timer stopped, buttons enabled, hour column hidden. |
|
| Filesize: |
37.25 KB |
| Viewed: |
7204 Time(s) |

|
| Description: |
| Stopwatch done, laps showing. |
|
| Filesize: |
27.81 KB |
| Viewed: |
7204 Time(s) |

|
| Description: |
| Timer running, buttons disabled, hour column showing. |
|
| Filesize: |
32.49 KB |
| Viewed: |
7204 Time(s) |

|
Last edited by noamwolf on Sun Dec 07, 2008 2:27 am; edited 1 time in total |
|
| Back to top |
|
 |
|
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Sun Nov 23, 2008 1:15 pm Post subject: |
|
|
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?)
|
|
| Back to top |
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sun Nov 23, 2008 4:24 pm Post subject: |
|
|
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
|
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Sun Nov 23, 2008 4:43 pm Post subject: |
|
|
| Yeah, I'd like to see it.
|
|
| Back to top |
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sun Nov 23, 2008 4:47 pm Post subject: |
|
|
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.
| Java: |
private SensorListener sensorListener = new SensorListener() {
public float accelerometer_shake_threshold = 50000;
static final int ACCELEROMETER_FLOAT_TO_INT = 1024;
public void onAccuracyChanged(int sensor, int accuracy) {
}
public void onSensorChanged(int sensor, float[] values) {
synchronized (this) {
if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
int ax = (int) (ACCELEROMETER_FLOAT_TO_INT * values[0]);
int ay = (int) (ACCELEROMETER_FLOAT_TO_INT * values[1]);
int az = (int) (ACCELEROMETER_FLOAT_TO_INT * values[2]);
int len2 = (ax * ax + ay * ay + az * az) / 1000;
if (len2 < accelerometer_shake_threshold) {
clockAppsReset();
}
}
}
};
|
Any comments/feedback would be greatly appreciated.
|
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Sun Nov 23, 2008 5:49 pm Post subject: |
|
|
| Your code register a looong acceleration in 1 direction too as a shake, doesn't it?
|
|
| Back to top |
|
 |
|
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sun Nov 23, 2008 5:54 pm Post subject: |
|
|
| Not sure I understand what you're asking. You can shake in any direction.
|
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Sun Nov 23, 2008 5:59 pm Post subject: |
|
|
| But if you keep accelerating in 1 direction, it will also register as a shake, won't it?
|
|
| Back to top |
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sun Nov 23, 2008 6:08 pm Post subject: |
|
|
| ah i see what you're saying. Yes, probably. Any suggestions on how to fix it?
|
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Sun Nov 23, 2008 6:20 pm Post subject: |
|
|
No, that's why I wanted your code
|
|
| Back to top |
|
 |
infotechsailor Once Poster

Joined: 02 Dec 2008 Posts: 1
|
Posted: Tue Dec 02, 2008 4:54 am Post subject: Re: [ClockApps] - Countdown Timer and Stopwatch |
|
|
| 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.
|
|
| Back to top |
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
|
| Back to top |
|
 |
noamwolf Junior Developer

Joined: 23 Nov 2008 Posts: 13
|
Posted: Sat Dec 06, 2008 5:13 pm Post subject: Version 1.0.16 is out |
|
|
I put out an update that fixes some bugs that have been reported. Check it out and please rate and write a review
Thanks!
|
|
| Back to top |
|
 |
wolfmankurd Freshman

Joined: 02 Jan 2010 Posts: 4
|
Posted: Sat Jan 02, 2010 11:26 pm Post subject: |
|
|
| 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.
|
|
| Back to top |
|
 |
|