I'm looking to create a simple calculator that will generate the sunrise and sunset for a given location (gps) for android.
I've come across these two approaches:
http://www.codeproject.com/KB/cs/suntimes.aspx http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
I'd just like some advice on the best way to approach this. I have a feeling that I could spend a lot of time on either approach and discover it's too compicated.
What approach would you suggest is best? I think the C# would probably be best. The lack of the .NET libraries would be a pain to convert.
Any advice appreciated.
Thanks.
Look at com.android.server.TwilightCalculator and TwilightService in android sources (but not in the compiled jar for some reason...). I haven't used it, but looks convenient, also calculates twilight dates.
The easiest route is to grab an algorithm written i c, for examle http://souptonuts.sourceforge.net/code/sunrise.c.html and use JNI to call it from your Android application. For this you will need the Android NDK. Just download and install the NDK and you will find some good sample code that shows you how to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With