編輯:高級開發
mWeatherCurrentTemperature = (TextView) findVIEwById(R.id.weather_temperature);
mWeatherHighTemperature = (TextView) findVIEwById(R.id.weather_high_temperature);
mWeatherLowTemperature = (TextView) findVIEwById(R.id.weather_low_temperature);
mWeatherLocation = (TextView) findVIEwById(R.id.weather_location);
mWeatherIcon = (ImageView) findVIEwById(R.id.weather_icon);
當然目前該版本尚未完整,其中有關天氣更新從獨立的服務中獲取天氣數據保存到content provider數據庫中,通過下面的代碼讀取:
private void queryWeatherData() {
// if we couldn't load the weather widget's resources, we simply
// assume it's not present on the device.
if (mGenIEResources == null) return;
Uri queryUri = new Uri.Builder()
.scheme(android.content.ContentResolver.SCHEME_CONTENT)
.authority(WEATHER_CONTENT_AUTHORITY)
.path(WEATHER_CONTENT_PATH)
.appendPath(new Long(System.currentTimeMillis()).toString())
.build();
if (DEBUG) Log.d(LOG_TAG, "querying genIE: " + queryUri);
Cursor cur;
try {
cur = managedQuery(
queryUri,
WEATHER_CONTENT_COLUMNS,
null,
null,
null);
} catch (RuntimeException e) {
Log.e(LOG_TAG, "Weather query failed", e);
cur = null;
}
if (cur != null && cur.moveToFirst()) {
if (DEBUG) {
Java.lang.StringBuilder sb =
new Java.lang.StringBuilder("Weather query result: {");
for(int i=0; i<cur.getColumnCount(); i++) {
if (i>0) sb.append(", ");
sb.append(cur.getColumnName(i))
.append("=")
.append(cur.getString(i));
}
sb.append("}");
Log.d(LOG_TAG, sb.toString());
}
mWeatherIconDrawable = mGenIEResources.getDrawable(cur.getInt(
cur.getColumnIndexOrThrow("iconResId")));
mWeatherLocationString = cur.getString(
cur.getColumnIndexOrThrow("location"));
// any of these may be NULL
final int colTemp = cur.getColumnIndexOrThrow("temperature");
final int colHigh = cur.getColumnIndexOrThrow("highTemperature");
final int colLow = cur.getColumnIndexOrThrow("lowTemperature");
mWeatherCurrentTemperatureString =
cur.isNull(colTemp)
? "\u2014"
: String.format("%d\u00b0", cur.getInt(colTemp));
mWeatherHighTemperatureString =
cur.isNull(colHigh)
? "\u2014"
: String.format("%d\u00b0", cur.getInt(colHigh));
mWeatherLowTemperatureString =
cur.isNull(colLow)
? "\u2014"
: String.format("%d\u00b0", cur.getInt(colLow));
} else {
Log.w(LOG_TAG, "No weather information available (cur="
+ cur +")");
mWeatherIconDrawable = null;
mWeatherLocationString = getString(R.string.weather_fetch_failure);
mWeatherCurrentTemperatureString =
mWeatherHighTemperatureString =
mWeatherLowTemperatureString = "";
}
mHandy.sendEmptyMessage(UPDATE_WEATHER_DISPLAY_MSG);
}
android智能手機上市等因素的影響下,全球移動上網用戶和使用量正快速增長。與此同時,android的移動網絡流量市場份額也是節節攀升,iPhone占全球移動網絡流量
/developer.android.com/sdk/installing.Html(洋文,被牆) 下載後解壓。 假設解壓後是/home/chen/下載/andro
報告中寫道:“android是首款受到強力消費品牌青睐的Linux操作系統,而他背後的這只強力推手則是谷歌。”報告並承認Android仍然處在不成熟的發展階段,不過他們
3.5 (Galileo).運行Eclipse 並選擇Help->Install New Software.在Available Software窗口中點擊Add