svn checkout http://android-sky.googlecode.com/svn/trunk/ android-sky-read-only
2. 更改source code,因為原本的source code使用android.location.Geocoder 由zip code or location name decode 成地點的Latitude & longitude,而Geocoder 僅能在actual device上work,所以在emulator要跑該widget則要hardcode地點的Latitude & longitude,而我們以"Chicago IL 41.9°N 87.67°W"為例,另外source code中的National Weather Service 的URL已經過時了也須更改,為何會知道要改這一個,我們可以透過"adb logcat"指令知道widget的excution log知道。
差不多在 WebserviceHelper.java的Line 162地方改成這樣:
countryCode="US";
Log.d(TAG, "using country code=" + countryCode);
lat=41.90;
lon=-87.65;
// Query webservice for this location
List
//if (COUNTRY_US.equals(countryCode)) {
forecasts = new NoaaSource().getForecasts(lat, lon, days);
// } else {
// forecasts = new MetarSource().getForecasts(lat, lon, days);
// }
差不多在NoaaSource.java的Line 48地方改成這樣
//static final String WEBSERVICE_URL = "http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?&lat=%f&lon=%f&format=24+hourly&numDays=%d";
static final String WEBSERVICE_URL= "http://www.weather.gov/forecasts/xml/SOAP_server/ndfdSOAPclientByDay.php?whichClient=NDFDgenByDay&lat=%f&lon=%f&format=24+hourly&numDays=%d";
reference:
http://jsharkey.org/blog/2009/04/24/forecast-widget-for-android-15-with-source/
http://groups.google.com/group/android-developers/browse_thread/thread/47a88c539a467ce8
http://code.google.com/p/android-sky/source/checkout
http://www.realestate3d.com/gps/latlong.htm
http://www.weather.gov/forecasts/xml/SOAP_server/ndfdSOAPclientByDay.php?whichClient=NDFDgenByDay&lat=%f&lon=%f&format=24+hourly&numDays=%d
For example:
Chicago IL 41.9°N 87.67°W
http://www.weather.gov/forecasts/xml/SOAP_server/ndfdSOAPclientByDay.php?whichClient=NDFDgenByDay&lat=41.90&lon=-87.65&format=24+hourly&numDays=4
http://forecast.weather.gov/MapClick.php?textField1=41.90&textField2=-87.65
http://blog.elsdoerfer.name/2009/06/03/writing-an-android-widget-what-the-docs-dont-tell-you/
http://developer.android.com/guide/developing/tools/adb.html
沒有留言:
張貼留言