这几周笔者几篇文章介绍了改调用对象的文章. 关联文章的址地
通过这一篇文章WebService的读书笔记对Web Service的意识,当初来写一个小用应Android通过调用Webservice现实气候预报来加强对Web Srevice的学习
在开辟气候预报的Android用应之前,首先须要找到一个可以对外供提气候预报的Web Service,通过搜索现发站点http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx可以对外供提气候预报的Web Service,因此程序会调用此站点的Web Service来现实气候预报。(注意:如果该站点的气候预报Web Service务服已停止,那么本程序将没法常正调用Web Service,那么气候预报的功能天然也就失效啦)
好啦,当初开始step by step地现实该用应程序。
step1:新建Android目项MyWeather
step2:取得并应用KSOAP包
在Android SDK中并没有供提调用WebService的库,因此,须要应用第三方的SDK来调用WebService。PC版本的WebService库非常丰富,但这些对Android说来过于宏大。合适机手的WebService客户端的SDK有一些,比拟用常的是KSOAP2。
KSOAP2 址地:http://code.google.com/p/ksoap2-android/
我下载的最新的是: ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar
选择我们的目项,右键菜单中 Build Path –> Add External Archives… 加增这个下载的包
step3:计划用应的UI界面 /res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:hint="@string/province" />
<!-- 让用户选择份省的Spinner -->
<Spinner android:id="@+id/province" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:hint="@string/city" />
<!-- 让用户选择市城的Spinner -->
<Spinner android:id="@+id/city" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- 表现天今气候的图片和文本框 -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/todayWhIcon1"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:id="@+id/todayWhIcon2"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/weatherToday"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<!-- 表现天明气候的图片和文本框 -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/tomorrowWhIcon1"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:id="@+id/tomorrowWhIcon2"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/weatherTomorrow"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<!-- 表现后天气候的图片和文本框 -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/afterdayWhIcon1"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:id="@+id/afterdayWhIcon2"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/weatherAfterday"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView android:id="@+id/weatherCurrent"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">气候预报</string>
<string name="btn_apply">查询</string>
<string name="text_hint">市城中文名</string>
<string name="province">份省</string>
<string name="city">市城</string>
</resources>
step3:编写调用Web Service的具工类 cn.roco.weather.WebServiceUtil.java
因为本程序重要须要调用如下三个Web Service作操:
a.取得份省:getRegionProvince法方
b.根据份省取得市城:getSupportCityString法方
c.根据市城取得气候:getWeather法方
为了让用应界面更加雅观,可以拜访http://www.webxml.com.cn/images/weather.zip下载各种气候标图,可以应用这些气候标图来丑化用应。
package cn.roco.weather;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class WebServiceUtil
{
// 义定Web Service的命名空间
static final String SERVICE_NS = "http://WebXml.com.cn/";
// 义定Web Service供提务服的URL
static final String SERVICE_URL =
"http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
// 调用程远 Web Service取得份省列表
public static List<String> getProvinceList()
{
/**
* 调用程远Web Service的getRegionProvince法方: 取得中国份省、直辖市、地域和与之对应的ID
* <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://WebXml.com.cn/">
<string>黑龙江,3113</string>
<string>吉林,3114</string>
<string>辽宁,3115</string>
<string>内蒙古,3116</string>
<string>河北,3117</string>
<string>河南,3118</string>
<string>山东,3119</string>
<string>山西,31110</string>
<string>江苏,31111</string>
<string>安徽,31112</string>
<string>陕西,31113</string>
<string>宁夏,31114</string>
<string>甘肃,31115</string>
<string>青海,31116</string>
<string>湖北,31117</string>
<string>湖南,31118</string>
<string>浙江,31119</string>
<string>江西,31120</string>
<string>福建,31121</string>
<string>贵州,31122</string>
<string>四川,31123</string>
<string>广东,31124</string>
<string>广西,31125</string>
<string>云南,31126</string>
<string>海南,31127</string>
<string>新疆,31128</string>
<string>西藏,31129</string>
<string>台湾,31130</string>
<string>北京,311101</string>
<string>上海,311102</string>
<string>天津,311103</string>
<string>重庆,311104</string>
<string>香港,311201</string>
<string>澳门,311202</string>
<string>钓鱼岛,311203</string>
</ArrayOfString>
*/
String methodName = "getRegionProvince"; //取得中国份省、直辖市、地域和与之对应的ID
// 创立HttpTransportSE传输对象,该对象用于调用Web Service作操
HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
ht.debug = true;
// 应用SOAP1.1协议创立Envelop对象
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// 实例化SoapObject对象,传入所要调用的Web Service的命名空间,Web Service法方名
SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
//将 soapObject对象设置为SoapSerializationEnvelope对象的传出SOAP消息
envelope.bodyOut = soapObject;
/**
* 因为什么这个网站是通过.NET对外供提Web Service的,
* 因此设置与.Net供提的Web Service持保较好的兼容性
*/
envelope.dotNet = true;
try
{
// 调用Web Service
ht.call(SERVICE_NS + methodName, envelope);
if (envelope.getResponse() != null)
{
// 取得务服器响应返回的SOAP消息
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName
+ "Result");
// 析解务服器响应的SOAP消息。
return parseProvinceOrCity(detail);
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
return null;
}
// 根据份省取得市城列表
public static List<String> getCityListByProvince(String province)
{
/**
* 调用的法方
* 取得持支的市城/地域称名和与之对应的ID
输入数参:theRegionCode = 省市、家国ID或称名,返回数据:一维字符串组数。
如:输入北京的theRegionCode:311101到得的返回结果为:
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://WebXml.com.cn/">
<string>北京,792</string>
<string>昌平,785</string>
<string>大兴,826</string>
<string>房山,827</string>
<string>怀柔,752</string>
<string>门头沟,788</string>
<string>密云,751</string>
<string>平谷,756</string>
<string>顺义,741</string>
<string>通州,3409</string>
<string>延庆,746</string>
<string>海淀,742</string>
<string>旭日,3408</string>
<string>丰台,795</string>
<string>石景山,794</string>
</ArrayOfString>
*/
String methodName = "getSupportCityString";
// 创立HttpTransportSE传输对象
HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
ht.debug = true;
// 实例化SoapObject对象
SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
// 添加一个求请数参
soapObject.addProperty("theRegionCode", province);
// 应用SOAP1.1协议创立Envelop对象
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.bodyOut = soapObject;
// 设置与.Net供提的Web Service持保较好的兼容性
envelope.dotNet = true;
try
{
// 调用Web Service
ht.call(SERVICE_NS + methodName, envelope);
if (envelope.getResponse() != null)
{
// 取得务服器响应返回的SOAP消息
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName
+ "Result");
// 析解务服器响应的SOAP消息。
return parseProvinceOrCity(detail);
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
return null;
}
// 析解务服器响应的SOAP消息。
private static List<String> parseProvinceOrCity(SoapObject detail)
{
List<String> result = new ArrayList<String>();
for (int i = 0; i < detail.getPropertyCount(); i++)
{
// 析解出每一个份省
result.add(detail.getProperty(i).toString().split(",")[0]);
}
return result;
}
// 根据市城取得市城体具气候情况
public static SoapObject getWeatherByCity(String cityName)
{
/**
* 取得气候预报数据 输入数参:市城/地域ID或称名,返回数据:一维字符串组数。
如:输入theCityCode:792(<string>北京,792</string>)到得的返回结果为:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://WebXml.com.cn/">
<string>直辖市 北京</string>
<string>北京</string>
<string>792</string>
<string>2013/04/30 03:47:53</string>
<string>本日气候实况:气温:14℃;风向/风力:风东 2级;湿度:21%</string>
<string>氛围质量:良;紫外线强度:强</string>
<string>
穿衣指数:提议着薄型套装等秋春过渡装。老年体弱者宜着套装。但日夜温差大较,注意当适增减衣服。 过敏指数:气候件条极易引发过敏,易过敏人群尽量少减外出,外出宜穿长衣长裤并佩戴好眼镜和口罩,外出归来时时及洁清手和口鼻。 运动指数:气候较好,但由于风力大较,推荐您在室内停止低强度运动,若在户外运动请注意避风。 洗车指数:合适洗车,未来延续两天无雨气候较好,合适擦洗车汽,蓝天白云、风和日丽将伴您的车子连日干净。 晾晒指数:气候不错,合适晾晒。紧赶把久未见阳光的衣物搬出来吸收一下太阳的滋味吧! 旅游指数:气候较好,风稍大,但温度合适,是个好气候哦。很合适旅游,您可以情尽地受享大天然的无限风光。 路况指数:气候较好,路面比拟燥干,路况较好。 恬静度指数:天白气候晴好,您在种这气候件条下,会觉感晚早凉快、恬静,午后偏热。 氛围污染指数:气象件条有利于氛围污染物浓缩、扩散和除清,可在室外常正动活。 紫外线指数:紫外线辐射强,提议涂擦SPF20右左、PA++的防晒护肤品。免避在10点至14点露暴于日光下。
</string>
<string>4月30日 晴</string>
<string>11℃/27℃</string>
<string>冬风3-4级转无延续风向风微</string>
<string>0.gif</string>
<string>0.gif</string>
<string>5月1日 晴转多云</string>
<string>12℃/25℃</string>
<string>无延续风向风微</string>
<string>0.gif</string>
<string>1.gif</string>
<string>5月2日 多云放晴</string>
<string>13℃/26℃</string>
<string>无延续风向风微</string>
<string>1.gif</string>
<string>0.gif</string>
<string>5月3日 多云转阴</string>
<string>11℃/23℃</string>
<string>无延续风向风微</string>
<string>1.gif</string>
<string>2.gif</string>
<string>5月4日 阴转多云</string>
<string>14℃/27℃</string>
<string>无延续风向风微</string>
<string>2.gif</string>
<string>1.gif</string>
</ArrayOfString>
*/
String methodName = "getWeather";
HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
ht.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
soapObject.addProperty("theCityCode", cityName);
envelope.bodyOut = soapObject;
// 设置与.Net供提的Web Service持保较好的兼容性
envelope.dotNet = true;
try
{
ht.call(SERVICE_NS + methodName, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName
+ "Result");
return detail;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}
听,是谁的琴声,如此凄凉,低调的音,缓慢的节奏,仿佛正诉说着什么。音低调得略微有些抖动,听起来似乎心也有些抖动,我觉感到一种压抑的沉闷气息,是否已凝结在这氛围中……
step4:编写适配器,用于表现数据 cn.roco.weather.ListAdapter.java
package cn.roco.weather;
import java.util.List;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class ListAdapter extends BaseAdapter
{
private Context context;
private List<String> values;
public ListAdapter(Context context , List<String> values)
{
this.context = context;
this.values = values;
}
@Override
public int getCount()
{
return values.size();
}
@Override
public Object getItem(int position)
{
return values.get(position);
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
TextView text = new TextView(context);
text.setText(values.get(position));
text.setTextSize(20);
text.setTextColor(Color.BLACK);
return text;
}
}
step5:程序的主用应cn.roco.weather.MyWeather.java
package cn.roco.weather;
import java.util.List;
import org.ksoap2.serialization.SoapObject;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;
public class MyWeather extends Activity
{
private Spinner provinceSpinner;
private Spinner citySpinner;
private ImageView todayWhIcon1;
private ImageView todayWhIcon2;
private TextView textWeatherToday;
private ImageView tomorrowWhIcon1;
private ImageView tomorrowWhIcon2;
private TextView textWeatherTomorrow;
private ImageView afterdayWhIcon1;
private ImageView afterdayWhIcon2;
private TextView textWeatherAfterday;
private TextView textWeatherCurrent;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
todayWhIcon1 = (ImageView) findViewById(R.id.todayWhIcon1);
todayWhIcon2 = (ImageView) findViewById(R.id.todayWhIcon2);
textWeatherToday = (TextView) findViewById(R.id.weatherToday);
tomorrowWhIcon1 = (ImageView) findViewById(R.id.tomorrowWhIcon1);
tomorrowWhIcon2 = (ImageView) findViewById(R.id.tomorrowWhIcon2);
textWeatherTomorrow = (TextView) findViewById(R.id.weatherTomorrow);
afterdayWhIcon1 = (ImageView) findViewById(R.id.afterdayWhIcon1);
afterdayWhIcon2 = (ImageView) findViewById(R.id.afterdayWhIcon2);
textWeatherAfterday = (TextView) findViewById(R.id.weatherAfterday);
textWeatherCurrent = (TextView) findViewById(R.id.weatherCurrent);
// 取得程序界面中选择份省、市城的Spinner组件
provinceSpinner = (Spinner) findViewById(R.id.province);
citySpinner = (Spinner) findViewById(R.id.city);
// 调用程远Web Service取得份省列表
List<String> provinces = WebServiceUtil.getProvinceList();
ListAdapter adapter = new ListAdapter(this, provinces);
// 应用Spinner表现份省列表
provinceSpinner.setAdapter(adapter);
// 当份省Spinner的选择项被转变时
provinceSpinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> source, View parent,
int position, long id)
{
// 根据份省取得市城列表
List<String> cities = WebServiceUtil
.getCityListByProvince(provinceSpinner.getSelectedItem()
.toString());
ListAdapter cityAdapter = new ListAdapter(MyWeather.this,
cities);
// 应用Spinner表现市城列表
citySpinner.setAdapter(cityAdapter);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
// 当市城Spinner的选择项被转变时
citySpinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> source, View parent,
int position, long id)
{
//现展气候预报的体具数据
showWeather(citySpinner.getSelectedItem().toString());
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
}
//现展气候预报的体具数据
private void showWeather(String city)
{
String weatherToday = null;
String weatherTomorrow = null;
String weatherAfterday = null;
String weatherCurrent = null;
int iconToday[] = new int[2];
int iconTomorrow[] = new int[2];
int iconAfterday[] = new int[2];
// 取得程远Web Service返回的对象
SoapObject detail = WebServiceUtil.getWeatherByCity(city);// 根据市城取得市城体具气候情况
// 取得气候实况
weatherCurrent = detail.getProperty(4).toString();
// 析解天今的气候情况
String date = detail.getProperty(7).toString();
weatherToday = "天今:" + date.split(" ")[0];
weatherToday = weatherToday + "\n气候:" + date.split(" ")[1];
weatherToday = weatherToday + "\n气温:"
+ detail.getProperty(8).toString();
weatherToday = weatherToday + "\n风力:"
+ detail.getProperty(9).toString() + "\n";
iconToday[0] = parseIcon(detail.getProperty(10).toString());
iconToday[1] = parseIcon(detail.getProperty(11).toString());
// 析解天明的气候情况
date = detail.getProperty(12).toString();
weatherTomorrow = "天明:" + date.split(" ")[0];
weatherTomorrow = weatherTomorrow + "\n气候:" + date.split(" ")[1];
weatherTomorrow = weatherTomorrow + "\n气温:"
+ detail.getProperty(13).toString();
weatherTomorrow = weatherTomorrow + "\n风力:"
+ detail.getProperty(14).toString() + "\n";
iconTomorrow[0] = parseIcon(detail.getProperty(15).toString());
iconTomorrow[1] = parseIcon(detail.getProperty(16).toString());
// 析解后天的气候情况
date = detail.getProperty(17).toString();
weatherAfterday = "后天:" + date.split(" ")[0];
weatherAfterday = weatherAfterday + "\n气候:" + date.split(" ")[1];
weatherAfterday = weatherAfterday + "\n气温:"
+ detail.getProperty(18).toString();
weatherAfterday = weatherAfterday + "\n风力:"
+ detail.getProperty(19).toString() + "\n";
iconAfterday[0] = parseIcon(detail.getProperty(20).toString());
iconAfterday[1] = parseIcon(detail.getProperty(21).toString());
// 新更当天的气候实况
textWeatherCurrent.setText(weatherCurrent);
// 新更表现天今气候的标图和文本框
textWeatherToday.setText(weatherToday);
todayWhIcon1.setImageResource(iconToday[0]);
todayWhIcon2.setImageResource(iconToday[1]);
// 新更表现天明气候的标图和文本框
textWeatherTomorrow.setText(weatherTomorrow);
tomorrowWhIcon1.setImageResource(iconTomorrow[0]);
tomorrowWhIcon2.setImageResource(iconTomorrow[1]);
// 新更表现后天气候的标图和文本框
textWeatherAfterday.setText(weatherAfterday);
afterdayWhIcon1.setImageResource(iconAfterday[0]);
afterdayWhIcon2.setImageResource(iconAfterday[1]);
}
// 具工法方,该法方责负把返回的气候标图字符串,转换为程序的图片源资ID。
private int parseIcon(String strIcon)
{
if (strIcon == null)
return -1;
if ("0.gif".equals(strIcon))
return R.drawable.a_0;
if ("1.gif".equals(strIcon))
return R.drawable.a_1;
if ("2.gif".equals(strIcon))
return R.drawable.a_2;
if ("3.gif".equals(strIcon))
return R.drawable.a_3;
if ("4.gif".equals(strIcon))
return R.drawable.a_4;
if ("5.gif".equals(strIcon))
return R.drawable.a_5;
if ("6.gif".equals(strIcon))
return R.drawable.a_6;
if ("7.gif".equals(strIcon))
return R.drawable.a_7;
if ("8.gif".equals(strIcon))
return R.drawable.a_8;
if ("9.gif".equals(strIcon))
return R.drawable.a_9;
if ("10.gif".equals(strIcon))
return R.drawable.a_10;
if ("11.gif".equals(strIcon))
return R.drawable.a_11;
if ("12.gif".equals(strIcon))
return R.drawable.a_12;
if ("13.gif".equals(strIcon))
return R.drawable.a_13;
if ("14.gif".equals(strIcon))
return R.drawable.a_14;
if ("15.gif".equals(strIcon))
return R.drawable.a_15;
if ("16.gif".equals(strIcon))
return R.drawable.a_16;
if ("17.gif".equals(strIcon))
return R.drawable.a_17;
if ("18.gif".equals(strIcon))
return R.drawable.a_18;
if ("19.gif".equals(strIcon))
return R.drawable.a_19;
if ("20.gif".equals(strIcon))
return R.drawable.a_20;
if ("21.gif".equals(strIcon))
return R.drawable.a_21;
if ("22.gif".equals(strIcon))
return R.drawable.a_22;
if ("23.gif".equals(strIcon))
return R.drawable.a_23;
if ("24.gif".equals(strIcon))
return R.drawable.a_24;
if ("25.gif".equals(strIcon))
return R.drawable.a_25;
if ("26.gif".equals(strIcon))
return R.drawable.a_26;
if ("27.gif".equals(strIcon))
return R.drawable.a_27;
if ("28.gif".equals(strIcon))
return R.drawable.a_28;
if ("29.gif".equals(strIcon))
return R.drawable.a_29;
if ("30.gif".equals(strIcon))
return R.drawable.a_30;
if ("31.gif".equals(strIcon))
return R.drawable.a_31;
return 0;
}
}
step6:AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0" package="cn.roco.weather">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MyWeather" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
step7:部署用应,观看行运效果
附注:本用应的码源在:http://pan.baidu.com/share/link?shareid=419671&uk=805959799
关于Web Service的用应还可以查看Android通过调用Webservice现实机手号码归属地查询停止学习
文章结束给大家分享下程序员的一些笑话语录: 现在社会太数字化了,所以最好是有一个集很多功能于一身的设备!